Class: BootstrapForm::FormBuilder
- Inherits:
-
ActionView::Helpers::FormBuilder
- Object
- ActionView::Helpers::FormBuilder
- BootstrapForm::FormBuilder
- Includes:
- 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
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.
Instance Method Summary collapse
- #add_default_form_attributes_and_form_inline(options) ⇒ Object
- #fields_for_with_bootstrap(record_name, record_object = nil, fields_options = {}, &block) ⇒ 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.
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/bootstrap_form/form_builder.rb', line 50 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.
5 6 7 |
# File 'lib/bootstrap_form/form_builder.rb', line 5 def acts_like_form_tag @acts_like_form_tag end |
#control_col ⇒ Object (readonly)
Returns the value of attribute control_col.
5 6 7 |
# File 'lib/bootstrap_form/form_builder.rb', line 5 def control_col @control_col end |
#has_error ⇒ Object (readonly)
Returns the value of attribute has_error.
5 6 7 |
# File 'lib/bootstrap_form/form_builder.rb', line 5 def has_error @has_error end |
#inline_errors ⇒ Object (readonly)
Returns the value of attribute inline_errors.
5 6 7 |
# File 'lib/bootstrap_form/form_builder.rb', line 5 def inline_errors @inline_errors end |
#label_col ⇒ Object (readonly)
Returns the value of attribute label_col.
5 6 7 |
# File 'lib/bootstrap_form/form_builder.rb', line 5 def label_col @label_col end |
#label_errors ⇒ Object (readonly)
Returns the value of attribute label_errors.
5 6 7 |
# File 'lib/bootstrap_form/form_builder.rb', line 5 def label_errors @label_errors end |
#layout ⇒ Object (readonly)
Returns the value of attribute layout.
5 6 7 |
# File 'lib/bootstrap_form/form_builder.rb', line 5 def layout @layout end |
Instance Method Details
#add_default_form_attributes_and_form_inline(options) ⇒ Object
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/bootstrap_form/form_builder.rb', line 62 def add_default_form_attributes_and_form_inline() [:html] ||= {} [:html].reverse_merge!(BootstrapForm.config.default_form_attributes) return unless [:layout] == :inline [:html][:class] = ([*[:html][:class]&.split(/\s+/)] + %w[row row-cols-auto g-3 align-items-center]) .compact.uniq.join(" ") end |
#fields_for_with_bootstrap(record_name, record_object = nil, fields_options = {}, &block) ⇒ Object
73 74 75 76 77 |
# File 'lib/bootstrap_form/form_builder.rb', line 73 def fields_for_with_bootstrap(record_name, record_object=nil, ={}, &block) = (record_object, ) record_object = nil if record_object.is_a?(Hash) && record_object. fields_for_without_bootstrap(record_name, record_object, , &block) end |