BootsFaces-OSP: Inputs with col-XX generate invalid Bootstrap markup
With the following XHTML:
<b:inputText value="test" col-xs="6" label="Message" label-col-xs="6"/>
I’d expect it to generate something like:
<div class="form-group">
<label for="message1" class="col-xs-6">Message</label>
<div class="col-xs-6">
<input type="text" class="form-control" id="message1"></input>
</div>
</div>
But it’s generating the following instead:
<div id="j_idt6:j_idt7" class="form-group ">
<label for="input_j_idt6:j_idt7" class=" col-xs-6 control-label">Message</label>
<input id="input_j_idt6:j_idt7" name="input_j_idt6:j_idt7" class="form-control" value="test" type="text"></div>
You can see that only the label has col-xs-X defined.
If I only set the size for the input, like <b:inputText value="test" col-xs="6" label="Message" />, I get the following:
<div class="col-xs-6" id="j_idt6:j_idt7">
<div class="form-group ">
<label for="input_j_idt6:j_idt7" class=" control-label">Message</label>
<input id="input_j_idt6:j_idt7" name="input_j_idt6:j_idt7" class="form-control" value="test" type="text">
</div>
</div>
form-group acts like row for forms, so it doesn’t seem to be correct to wrap the row with a column. Also, the input size shouldn’t be ignored when setting the label width. This is needed in order to allow for more complex form designs (such as https://jsbin.com/jikiyuwuve/edit?html,output). Although more customization options will be needed for that. I’ll open an issue for that later.
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 15 (2 by maintainers)
Commits related to this issue
- #682 and #685 added the formGroup component to the ComponentsEnum class, and added the datePicker:label attribute to the BootsFaces.jsfdsl — committed to TheCoder4eu/BootsFaces-OSP by stephanrauh 10 years ago
Hi,
You are right, he form class is effectively needed for added styles. But anyway, there are two problems with the markup not complaining with BS rules (at least to my understanding):
Yes, it’s a breaking change. But it depends on how you look at it. For me, if it generates wrong Bootstrap markup, that’s a priority to fix. And any behaviour depending on “wrong” markup can’t be taken for granted.
If not breaking BC in this cases is really a concern, I’d propose to use a context param to revert to the original markup. But that’s also more maintenance work…
A middleground aproach (given the times wr have) would be to add an option to inputs to just generate the input, without any added form-group markup, leaving the user the option to customize as needed.
But, for that case, I was going to propose the addition of a new b:formGroup component that generates just the form group div and prevents its generation for inputs that were direct children.
In other words, inputs would check if their parent is a b:formGroup and in that case, they would not generate the form-group div. That would allow for multi input rows without custom html and just using BS styles.
Not sure however how hard could it be.
El jue., 6 de abril de 2017 20:30, Stephan Rauh notifications@github.com escribió: