bootstrap-ruby / bootstrap_form

Official repository of the bootstrap_form gem, a Rails form builder that makes it super easy to create beautiful-looking forms using Bootstrap 5.
MIT License
1.64k stars 351 forks source link

Error messages don't display on form_group #655

Closed suketk closed 9 months ago

suketk commented 1 year ago

I have a set of radio buttons in my form group that don't show error messages.

When there is an error, the radio buttons and respective labels turn red, but there's no message.

I can confirm there's an error because the error summary prints it, but it's not displayed by the field.

If I use errors_on, the .invalid-feedback div appears in the DOM but it's hidden because there's no CSS rule (in Bootstrap?) that matches it.

I believe this is a bug, unless I'm missing something simple.

Example below:

The associated model has a presence validation for the :test field.

<%= f.form_group :test, label: {text: 'Label'}, help: 'Help', class: 'mb-5 linear' do %>

  <%= f.radio_button :test, 1, label: 1, inline: true %>
  <%= f.radio_button :test, 2, label: 2, inline: true %>
  <%= f.radio_button :test, 3, label: 3, inline: true %>

<% end %>
donv commented 9 months ago

Hi @suketk !

Is this still a problem for you?

donv commented 9 months ago

The logic to append the error message for the field to the last option for the field is attached to the collection_* methods. It is possible to extract it from there and add it to the form_group method.

@suketk Please respond if this would be useful for you.