Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inputs with col-XX generate invalid Bootstrap markup #682

Closed
ggam opened this issue Apr 6, 2017 · 15 comments
Closed

Inputs with col-XX generate invalid Bootstrap markup #682

ggam opened this issue Apr 6, 2017 · 15 comments

Comments

@ggam
Copy link
Collaborator

ggam commented Apr 6, 2017

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.

@stephanrauh
Copy link
Collaborator

The markup is wrong because you didn't add <form horizontal="true">. (Or at least I hope so because it was so hard and painful to get it right :)).

Have a look at http://www3.bootsfaces.net/Showcase/forms/horizontalForms.jsf for more details.

Should we emit an error message, or should we silently correct the html code the way you suggest? In that case, I'd like to postpone it to BootsFaces 1.2 because it's a breaking change and because it's very difficult to get it right. There are so many options (AJAX vs. non-AJAX, facets, horizontal forms, stacked forms, inline forms, and last not least input fields without the col-* attributes).

@ggam
Copy link
Collaborator Author

ggam commented Apr 6, 2017 via email

@stephanrauh
Copy link
Collaborator

Let's think about the good solution first. If we find out we don't have enough time, we can still opt for the quick-and-dirty solution.

According to StackOverflow and my own test form-group only acts as a row if place within a horizontal-form. I don't know if that changes anything (probably not), but let's keep that in mind.

Basically, the simplest bugfix that comes to mind is to switch the form-group div and the col-* div. I think we can do that at low risk.

What happens if the form-group happens to be within a b:row? Probably not much, but we should check that, too.

I also agree with your proposal to add a b:formGroup tag. The current solution is too inflexible. b:formGroup sounds like a welcome addition.

Would you like to prepare a pull request?

@stephanrauh
Copy link
Collaborator

stephanrauh commented Apr 6, 2017

Components to modify and test (please add components if something's missing!):

Regular (stacked) forms:

  • b:inputText
  • b:inputText with appending / prepending facet
  • b:colorPicker
  • b:colorPicker with appending / prepending facet
  • b:selectOneMenu
  • b:selectOneMenu with appending / prepending facet
  • b:selectMultiMenu
  • b:selectMultiMenu with appending / prepending facet
  • b:datepicker
  • b:datepicker with appending / prepending facet
  • b:dateTimePicker
  • b:dateTimePicker with appending / prepending facet

Inline forms:

  • b:inputText
  • b:inputText with appending / prepending facet
  • b:colorPicker
  • b:colorPicker with appending / prepending facet
  • b:selectOneMenu
  • b:selectOneMenu with appending / prepending facet
  • b:selectMultiMenu
  • b:selectMultiMenu with appending / prepending facet
  • b:datepicker
  • b:datepicker with appending / prepending facet
  • b:dateTimePicker
  • b:dateTimePicker with appending / prepending facet

Horizontal forms:

  • b:inputText
  • b:inputText with appending / prepending facet
  • b:colorPicker
  • b:colorPicker with appending / prepending facet
  • b:selectOneMenu
  • b:selectOneMenu with appending / prepending facet
  • b:selectMultiMenu
  • b:selectMultiMenu with appending / prepending facet
  • b:datepicker
  • b:datepicker with appending / prepending facet
  • b:dateTimePicker
  • b:dateTimePicker with appending / prepending facet

Components wrapped inside a <b:formGroup> tag:

  • b:inputText
  • b:inputText with appending / prepending facet
  • b:colorPicker
  • b:colorPicker with appending / prepending facet
  • b:selectOneMenu
  • b:selectOneMenu with appending / prepending facet
  • b:selectMultiMenu
  • b:selectMultiMenu with appending / prepending facet
  • b:datepicker
  • b:datepicker with appending / prepending facet
  • b:dateTimePicker
  • b:dateTimePicker with appending / prepending facet

@ggam
Copy link
Collaborator Author

ggam commented Apr 7, 2017

@stephanrauh Exactly, the solution would be to:

  • Basically switch the form-group and col-xs-X position
  • Render the col-X for the input even when the label already has a size.

I doubt nobody is relying on the current markup so I think we can safely change it.

I'll try to make a PR for the b:formGroup component over the weekend. Doesn't seem to be difficult. I'll ask for help if I need it.

@stephanrauh
Copy link
Collaborator

This bug is also related to #614 and #493.

@NicolaIsotta Please have a look at PR #685. @ggam currently implements a <b:formGroup> widget. Does this solve your issue #493, too?

@stephanrauh
Copy link
Collaborator

ToDos left:

  • testing
  • documenting <b:formGroup>

@stephanrauh stephanrauh added this to In Progress in BootsFaces v1.1.0 Apr 8, 2017
stephanrauh added a commit that referenced this issue Apr 8, 2017
…ss, and added the datePicker:label attribute to the BootsFaces.jsfdsl
@NicolaIsotta
Copy link
Contributor

NicolaIsotta commented Apr 8, 2017

@stephanrauh I guess this fixes #493
But, @ggam , I'm afraid this breaks #621 : b:formGroup should retrieve error style classes from his children.

@ggam
Copy link
Collaborator Author

ggam commented Apr 8, 2017 via email

@stephanrauh
Copy link
Collaborator

These components have become so powerful, improving them always feels like playing Mikado :).

@ggam Thanks for offering a new PR!

@ggam
Copy link
Collaborator Author

ggam commented Apr 8, 2017

@NicolaIsotta I've started to implement a solution on #689

@ggam
Copy link
Collaborator Author

ggam commented Apr 9, 2017

@NicolaIsotta plese have a look at #689. I think I've fixed it now.

@NicolaIsotta
Copy link
Contributor

It seems ok at first glance. I'll test it once it's merged.

@stephanrauh
Copy link
Collaborator

I've merged the PR. Happy testing!

@stephanrauh
Copy link
Collaborator

I'll close this issue for the moment. I keep listening to the comments. If bugs occur during testing, I'm ready to re-open the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

No branches or pull requests

3 participants