From 693a0e00fd7f73f1ea0744bb2f60fa78f14a8f65 Mon Sep 17 00:00:00 2001 From: wengs Date: Fri, 22 May 2015 13:32:16 -0700 Subject: [PATCH] Add explanation on how to display errors inside fields_for --- _includes/forms.html | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/_includes/forms.html b/_includes/forms.html index 3e526e4..d5813de 100644 --- a/_includes/forms.html +++ b/_includes/forms.html @@ -515,6 +515,23 @@

Errors

{% endhighlight %} +

Note that fields inside fields_for submitted with invalid values are not automatically highlighted. The :errors options should be specified explicity so that BH recognizes the :errors options.

+ {% highlight rhtml %} +<%= f.fields_for :company, fields_set: false, errors: {icons: true, messages: true} do |company_form| %> + <%= company_form.text_field :name %> +<% end %> + {% endhighlight %} +

However, error messages in the association attribute should still be displayed manually.

+ {% highlight rhtml %} +<% if @user.company.errors.any? %> + +<% end %> + {% endhighlight %} +

Help text

Use the :help option to display a help message after fields inside bootstrapped forms.

Note that error messages will have precedence over help messages.