-
Notifications
You must be signed in to change notification settings - Fork 110
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
Inline errors for toggles #9
Comments
I'll commit a fix tomorrow morning. Thanks for the report and code! |
"Tomorrow morning" was perhaps a bit ambitious. I hope you'll accept "Today Evening". |
Hm. This actually is somewhat of an issue. Twitter Bootstrap only styles errors with a red highlight if wrapped with a div having a class "clearfix". But the clearfix divs also create a bunch of extra margins. Another issue is the radio buttons — they differ from checkboxes, in that the whole group should be highlighted as invalid. With checkboxes, only one ought to be. Right now I'm handling them in a I'm not sure what to do about this. |
The reason for the |
Any further ideas on this issue? I'm in a holding pattern until I have a better idea of how to solve it. |
Thanks for looking into this! Checkboxes are important also. When I figure out a longer term solution for my project, I'll share it, but it might be a couple weeks. |
I'll hold off on anything for the time being. |
Meh, I'd suggest doing something simple that will work. Adding the error class to the ul for checkboxes would cause the whole thing to be highlighted. I think that's better than nothing. It's not a perfect solution, but it's forward movement, I think. |
I'm gravitating towards not supporting these. My suspicion is that having errors on checkboxes or radio buttons is probably just bad UI. In the classic example of "You must agree to the terms and conditions...", the appropriate way to handle it is how Github does: "By clicking on 'Create an account' below, you are agreeing...". Is this a showstopper for anyone? I'm open to counter arguments (hence leaving this bug open for comment), but given Twitter Bootstrap's lack of support or guidance for this, plus my own predilections, I'm leaning towards not supporting this behavior. |
Seems reasonable to me. |
I object on the basis of consistency :) Seriously, if we can't get inline errors for all the standard inputs, I'd rather none at all. Let's not deceive people migrating from eg. formtastic by claiming to support inline errors. I agree the terms and conditions checkbox case is marginal, but what about these, not uncommon, cases?
|
I just played around with errors for checkboxes and radio buttons on the latest Bootstrap examples available. It looks like the only styling that works is to add an "error" class to the This now causes a problem. The I could conceivably split out / group of radio buttons
= user.radio_buttons :email, 'Email Preferences' do
= user.radio_button :email, 'HTML Email', :html, :checked => true
= user.radio_button :email, 'Plain Text', :plain This would work fine. The / group of checkboxes
= user.check_boxes $WHAT_GOES_HERE, 'Agreements' do
= user.check_box :agree, 'I agree to the abusive Terms and Conditions'
= user.check_box :spam, 'I agree to receive all sorts of spam'
= user.check_box :spammer, 'I agree to let the site spam others through my Twitter account' The checkbox group encompasses multiple attributes. I could specify all the attributes as an array passed to the I could conceivably support the |
I like that idea a lot, very pragmatic. |
I would argue that those are really three separate checkboxes with independent errors. I'd probably render them as such by using 3 In my experience, at least, the much more likely use case for multiple checkboxes is when they are mapped to a single field.
In this case, it'd work just like the radio button example, right? FWIW, I couldn't get this arrangement to be marked up correctly with current version last night, so I had to work around it. Clicking the labels for the independent checkboxes always selected the first checkbox because the checkboxes all have the same name. Checkboxes should probably be wrapped by the label tag instead. I ended up doing:
I considered opening it as a separate issue, but if you're consiering overhauling the checkbox code here anyway... |
From the Rails documentation, you probably need to be using |
Ok. I plan on doing as I said above: support this for radio buttons, but not currently for checkboxes. Will try to get a patch out this weekend. |
This still seems to be open and is causing me problems. I made a branch and fixed it for check_boxes only like so: The clearfix does cause some margin but I think it looks fine. I have a screenshot here: Is this okay? If so maybe we could do the split of radios and checkboxes? |
Fair enough. Issue a pull request and I'll merge it in. |
Done. Happy to help with something less hacky if you prefer. |
2.0 is going to be released soon. Kind of in a holding pattern until it comes out. |
Makes sense, thanks. |
As far as I can tell, master is missing inline errors for toggles.
I wrote a quick fix so that I can use this library on a project, but it's not pull-worthy: coshx@36ca5db
If I understood the reason for the toggle abstraction, I'd try to come up with a real fix.
The text was updated successfully, but these errors were encountered: