[ 
https://issues.apache.org/jira/browse/WICKET-6516?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16621956#comment-16621956
 ] 

Maksim Atanasov commented on WICKET-6516:
-----------------------------------------

I've tried fixing this issue, however it seems that when the AutoLabelResolver 
finds the associated input field it is already rendered because it comes before 
the label. The component does get a markupId, but it is set too late. So it 
seems that one has to call `setOutputMarkupId(true)` when adding the component 
to the page to have this work. 

Maybe this should be documented somewhere if it isn't already.

 

> wicket:for on a label placed after the input doesn't generate id on the input
> -----------------------------------------------------------------------------
>
>                 Key: WICKET-6516
>                 URL: https://issues.apache.org/jira/browse/WICKET-6516
>             Project: Wicket
>          Issue Type: Bug
>    Affects Versions: 8.0.0-M8
>            Reporter: Virginie Garcin
>            Priority: Minor
>
> When using wicket:for on a label placed after the input, the id is not 
> automatically set on the related input, except if we force it by using 
> setOutputMarkupId(true).
> The attribute wicket:for by itself should force the id of the input to be 
> output, no matter if it is placed before or after the label, because like 
> that it's not consistent.
> Moreover, Bootstrap 4 custom checkboxes dictates us to put the label after 
> the input ( 
> https://getbootstrap.com/docs/4.0/components/forms/#checkboxes-and-radios-1 ).
> I feel that having to force the setOutputMarkupId(true) to the checkbox 
> everytime we use a checkbox isn't a clean solution.
> Example:
> {noformat}
> HTML:
> <div class="custom-control custom-checkbox">
>     <input wicket:id="active" type="checkbox" class="custom-control-input"/>
>     <label wicket:for="active" class="custom-control-label">Active</label>
> </div>
> Java:
> form.add( new CheckBox( "active" ) );
> Output HTML: the "for" on the label is there but the "id" on the input is 
> missing.
> <div class="custom-control custom-checkbox">
>     <input class="custom-control-input beingEdited pristine" 
> checked="checked" name="variations:0:active" type="checkbox">
>     <label class="custom-control-label" id="activebb-w-lbl" 
> for="activebb">Active</label>
> </div>
> {noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to