Class: TemplateForm::FormBuilder
- Inherits:
-
ActionView::Helpers::FormBuilder
- Object
- ActionView::Helpers::FormBuilder
- TemplateForm::FormBuilder
- Defined in:
- lib/template_form/form_builder.rb
Instance Attribute Summary collapse
-
#form_type ⇒ Object
readonly
Returns the value of attribute form_type.
Instance Method Summary collapse
- #hidden(attribute_name, options = {}) ⇒ Object
-
#initialize ⇒ FormBuilder
constructor
A new instance of FormBuilder.
- #input(attribute_name, options = {}) ⇒ Object
Constructor Details
#initialize ⇒ FormBuilder
19 20 21 22 23 24 |
# File 'lib/template_form/form_builder.rb', line 19 def initialize(...) super = [:parent_builder]&. @form_type = [:form_type] || &.dig(:form_type) || TemplateForm.form_type @view = [:view] || &.dig(:view) end |
Instance Attribute Details
#form_type ⇒ Object (readonly)
Returns the value of attribute form_type.
17 18 19 |
# File 'lib/template_form/form_builder.rb', line 17 def form_type @form_type end |
Instance Method Details
#hidden(attribute_name, options = {}) ⇒ Object
39 40 41 |
# File 'lib/template_form/form_builder.rb', line 39 def hidden(attribute_name, = {}) hidden_field attribute_name, end |
#input(attribute_name, options = {}) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/template_form/form_builder.rb', line 26 def input(attribute_name, = {}) attribute_type = .delete(:as) || (@object.respond_to?(:type_for_attribute) && @object.type_for_attribute(attribute_name).type) || :string [:type] ||= 'password' if attribute_name.match(/password/) .merge! view: @view if @view input_for(attribute_type).new(self, attribute_name, ).render end |