Class: BootstrapForm::FormBuilder
- Inherits:
-
ActionView::Helpers::FormBuilder
- Object
- ActionView::Helpers::FormBuilder
- BootstrapForm::FormBuilder
- Includes:
- ActionView::Helpers::OutputSafetyHelper, Components, FormGroup, FormGroupBuilder, Helpers::Bootstrap, Helpers::Field, Inputs::Base, Inputs::CheckBox, Inputs::CollectionCheckBoxes, Inputs::CollectionRadioButtons, Inputs::CollectionSelect, Inputs::ColorField, Inputs::DateField, Inputs::DateSelect, Inputs::DatetimeField, Inputs::DatetimeLocalField, Inputs::DatetimeSelect, Inputs::EmailField, Inputs::FileField, Inputs::GroupedCollectionSelect, Inputs::MonthField, Inputs::NumberField, Inputs::PasswordField, Inputs::PhoneField, Inputs::RadioButton, Inputs::RangeField, Inputs::RichTextArea, Inputs::SearchField, Inputs::Select, Inputs::Submit, Inputs::TelephoneField, Inputs::TextArea, Inputs::TextField, Inputs::TimeField, Inputs::TimeSelect, Inputs::TimeZoneSelect, Inputs::UrlField, Inputs::WeekField
- Defined in:
- lib/bootstrap_form/form_builder.rb
Overview
rubocop:disable Metrics/ClassLength
Instance Attribute Summary collapse
-
#acts_like_form_tag ⇒ Object
readonly
Returns the value of attribute acts_like_form_tag.
-
#control_col ⇒ Object
readonly
Returns the value of attribute control_col.
-
#has_error ⇒ Object
readonly
Returns the value of attribute has_error.
-
#inline_errors ⇒ Object
readonly
Returns the value of attribute inline_errors.
-
#label_col ⇒ Object
readonly
Returns the value of attribute label_col.
-
#label_errors ⇒ Object
readonly
Returns the value of attribute label_errors.
-
#layout ⇒ Object
readonly
Returns the value of attribute layout.
Class Method Summary collapse
Instance Method Summary collapse
- #add_default_form_attributes_and_form_inline(options) ⇒ Object
- #fields_for_with_bootstrap(record_name, record_object = nil, fields_options = {}) ⇒ Object
-
#initialize(object_name, object, template, options) ⇒ FormBuilder
constructor
A new instance of FormBuilder.
Methods included from Inputs::Submit
Methods included from FormGroup
Methods included from Helpers::Bootstrap
#alert_message, #custom_control, #error_summary, #errors_on, #input_group_content, #input_with_error, #prepend_and_append_input, #static_class, #static_control
Methods included from Helpers::Field
Constructor Details
#initialize(object_name, object, template, options) ⇒ FormBuilder
Returns a new instance of FormBuilder.
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/bootstrap_form/form_builder.rb', line 60 def initialize(object_name, object, template, ) warn_deprecated_layout_value() @layout = [:layout] || default_layout @label_col = [:label_col] || default_label_col @control_col = [:control_col] || default_control_col @label_errors = [:label_errors] || false @inline_errors = [:inline_errors].nil? ? @label_errors != true : [:inline_errors] != false @acts_like_form_tag = [:acts_like_form_tag] add_default_form_attributes_and_form_inline super end |
Instance Attribute Details
#acts_like_form_tag ⇒ Object (readonly)
Returns the value of attribute acts_like_form_tag.
7 8 9 |
# File 'lib/bootstrap_form/form_builder.rb', line 7 def acts_like_form_tag @acts_like_form_tag end |
#control_col ⇒ Object (readonly)
Returns the value of attribute control_col.
7 8 9 |
# File 'lib/bootstrap_form/form_builder.rb', line 7 def control_col @control_col end |
#has_error ⇒ Object (readonly)
Returns the value of attribute has_error.
7 8 9 |
# File 'lib/bootstrap_form/form_builder.rb', line 7 def has_error @has_error end |
#inline_errors ⇒ Object (readonly)
Returns the value of attribute inline_errors.
7 8 9 |
# File 'lib/bootstrap_form/form_builder.rb', line 7 def inline_errors @inline_errors end |
#label_col ⇒ Object (readonly)
Returns the value of attribute label_col.
7 8 9 |
# File 'lib/bootstrap_form/form_builder.rb', line 7 def label_col @label_col end |
#label_errors ⇒ Object (readonly)
Returns the value of attribute label_errors.
7 8 9 |
# File 'lib/bootstrap_form/form_builder.rb', line 7 def label_errors @label_errors end |
#layout ⇒ Object (readonly)
Returns the value of attribute layout.
7 8 9 |
# File 'lib/bootstrap_form/form_builder.rb', line 7 def layout @layout end |
Class Method Details
.redefine_rich_text_area? ⇒ Boolean
11 12 13 |
# File 'lib/bootstrap_form/form_builder.rb', line 11 def redefine_rich_text_area? ActionView::Helpers::FormBuilder.instance_methods.any? { _1 == :rich_text_area } end |
Instance Method Details
#add_default_form_attributes_and_form_inline(options) ⇒ Object
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/bootstrap_form/form_builder.rb', line 72 def add_default_form_attributes_and_form_inline() [:html] ||= {} [:html].reverse_merge!(BootstrapForm.config.default_form_attributes) return unless [:layout] == :inline [:html][:class] = safe_join(([*[:html][:class]&.split(/\s+/)] + %w[row row-cols-auto g-3 align-items-center]) .compact.uniq, " ") end |
#fields_for_with_bootstrap(record_name, record_object = nil, fields_options = {}) ⇒ Object
83 84 85 86 87 |
# File 'lib/bootstrap_form/form_builder.rb', line 83 def fields_for_with_bootstrap(record_name, record_object=nil, ={}, &) = (record_object, ) record_object = nil if record_object.is_a?(Hash) && record_object. fields_for_without_bootstrap(record_name, record_object, , &) end |