Class: UiBibzForm::UiBibzFormBuilder
- Inherits:
-
SimpleForm::FormBuilder
- Object
- SimpleForm::FormBuilder
- UiBibzForm::UiBibzFormBuilder
- Includes:
- ActionView::Helpers::TagHelper, ActionView::Helpers::TextHelper, UiBibz::Utils
- Defined in:
- lib/ui_bibz/inputs/ui_bibz_form/ui_bibz_form_builder.rb
Overview
if defined?(SimpleForm)
Instance Attribute Summary collapse
-
#output_buffer ⇒ Object
Returns the value of attribute output_buffer.
Instance Method Summary collapse
- #ui_button_group(content = nil, opts = nil, html_options = nil, &block) ⇒ Object
- #ui_choice_group(content = nil, opts = nil, html_options = nil, &block) ⇒ Object
- #ui_surround_field(content = nil, opts = nil, html_options = nil, &block) ⇒ Object
Instance Attribute Details
#output_buffer ⇒ Object
Returns the value of attribute output_buffer.
10 11 12 |
# File 'lib/ui_bibz/inputs/ui_bibz_form/ui_bibz_form_builder.rb', line 10 def output_buffer @output_buffer end |
Instance Method Details
#ui_button_group(content = nil, opts = nil, html_options = nil, &block) ⇒ Object
34 35 36 |
# File 'lib/ui_bibz/inputs/ui_bibz_form/ui_bibz_form_builder.rb', line 34 def (content = nil, opts = nil, = nil, &block) ui_component_group_by(UiBibz::Ui::Core::Forms::Buttons::ButtonGroup, content, opts, , &block) end |
#ui_choice_group(content = nil, opts = nil, html_options = nil, &block) ⇒ Object
38 39 40 |
# File 'lib/ui_bibz/inputs/ui_bibz_form/ui_bibz_form_builder.rb', line 38 def ui_choice_group(content = nil, opts = nil, = nil, &block) ui_component_group_by(UiBibz::Ui::Core::Forms::Choices::ChoiceGroup, content, opts, , &block) end |
#ui_surround_field(content = nil, opts = nil, html_options = nil, &block) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ui_bibz/inputs/ui_bibz_form/ui_bibz_form_builder.rb', line 12 def ui_surround_field(content = nil, opts = nil, = nil, &block) content = ( || {}).merge(content || {}) content = content.merge(template: @template, form: self) input_classes = UiBibz::Utils::Screwdriver.join_classes('form-group', 'surround_field', [:input_html].try(:[], :class)) wrapper_html = ([:input_html] || {}).merge({ class: input_classes }) surround_field = UiBibz::Ui::Core::Forms::Surrounds::SurroundField.new(content, opts, ).tap(&block) errors_text = surround_field.errors.flatten.to_sentence required = surround_field.required_fields.any?(true) wrapper_classes = UiBibz::Utils::Screwdriver.join_classes(('has-error' if errors_text.present?), wrapper_html.try(:[], :class)) label_classes = UiBibz::Utils::Screwdriver.join_classes(('required' if required), 'control-label') abbr_html = content_tag('abbr', I18n.t(:'simple_form.required.mark', default: '*'), title: I18n.t(:'simple_form.required.text', default: 'required')) if required wrapper_html[:class] = wrapper_classes content_tag :div, wrapper_html do concat content_tag(:label, "#{abbr_html} #{content[:label]}".html_safe, class: label_classes) if content[:label] concat surround_field.render concat content_tag(:span, errors_text || content[:hint], class: 'help-block') if errors_text.present? || !content[:hint].nil? end end |