Module: FormGroupHelper::FormBuilderExtensions
- Defined in:
- app/helpers/form_group_helper.rb
Instance Method Summary collapse
-
#form_group(attribute, opts = {}, &block) ⇒ Object
Return a ControlGroupBuilder that can display error message specific to a single model attribute.
Instance Method Details
#form_group(attribute, opts = {}, &block) ⇒ Object
Return a ControlGroupBuilder that can display error message specific to a single model attribute. Usage inside a FormBuilder:
<%= f.form_group :name do |f| %>
...
<%= f.error_messages %> <== helper method only accessible inside the control_group block.
<% end %>
39 40 41 42 43 44 |
# File 'app/helpers/form_group_helper.rb', line 39 def form_group(attribute, opts={}, &block) css_error_class = opts[:css_error_class] || 'has-danger' builder = FormGroupBuilder.new(@template, attribute, self) @template.content_tag :div, @template.capture(builder, &block), :class => "form-group #{opts[:class]} #{css_error_class if builder.has_errors?}" end |