bootstrap_form
bootstrap_form copied to clipboard
How to keep help message and inline error with bootstrap form?
Hi,
I have used bootstrap nested form like,
<%= bootstrap_nested_form_for(@user) do |f| %>
<%= f.email_field :email,help: 'Hint comes here' %>
<% end %>
When there is error on the page it will replace help span with inline error span. How to keep both help and inline error without using lebel_error and f.alert_message.
Hi, I believe this problem applies to bootstrap_form_for
as well. Generally, bootstrap_form will omit the help message when an error is present.
I don't know if this is intentional, or if it is a legitimate bug.
I've added the "discuss!" label on this issue to encourage some discussion on this topic. If you have a strong feeling as to whether this a bug or not, please let us know!
Any update?
This would be a breaking change, so I'd like to give the community a chance to provide input by commenting here.
For the time being, I don't plan on implementing this. If there is a lot of demand for it and someone comes forward with a PR, then perhaps that will change.
I've been looking at this code while working on #418. It sure looks to me like it was a deliberate decision to hide the help if there's an error. I think I would prefer to keep the help when there's an error, but I can't say I have real end-user feedback to say which is preferable.
I'm curious (for my own education) as to why this would be considered a breaking change?
Perhaps we could start down the path of configuration options. We could have a config file that allows specifying whether to show both error and help, or error replaces help. We could set default as show new behaviour and let people set the option for legacy/error overrides help.
I have an idea why errors replace help text. In Bootstrap 3 invalidation css class was on the wrapper. So help text under the input effectively became error message. See: https://getbootstrap.com/docs/3.3/css/#forms-control-validation
I'd like to argue for changing the behaviour of help and validation errors for version 4. I'm mainly putting this forward now because as a breaking change, we have to address it for this release or wait until the next major release.
#444 shows that in one case, Bootstrap 4 requires error and help to be rendered at different places in the structure (errors inside .input-group
and help outside). Either we code some contortions (not big ones, but still...) to have errors override help, or we admit that it would actually be preferable to show help and errors if we have both.
@mattbrictson @desheikh @duleorlovic what do you think?
Yes, it looks like Bootstrap v4 leaves us no choice. We have to handle help and errors separately (since they render in different locations in v4), so we should display both.
@mattbrictson #444 managed to fix its issue without changing the behaviour, i.e. error messages still suppress help text. However, it would be really easy to display both now. Let us know if you want to fix this for v4.0, or else perhaps remove the milestone from this issue. Thanks in advance.
Let's work on getting 4.0.0 out the door first, and come back to this later. I will remove the milestone.
yep, help message should to be with form-control in <div class="col-sm-10">..
, not after label/control