Class: ActionForm::Rails::Subform
- Defined in:
- lib/action_form/rails/subform.rb
Overview
Subform class for ActionForm that handles nested form structures. It allows building forms within forms, supporting has_one and has_many relationships. Includes schema and element DSL functionality for defining form elements.
Instance Attribute Summary
Attributes inherited from Subform
#elements_instances, #helpers, #name, #object, #tags
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Subform
#build_from_object, #html_id, #initialize, #render?, #template_html_id, #view_template
Methods included from ElementsDSL
Methods included from SchemaDSL
Methods included from ActionForm::Rendering
#render_element, #render_elements, #render_form, #render_inline_errors, #render_input, #render_label, #render_many_subforms, #render_new_subform_button, #render_remove_subform_button, #render_subform, #render_submit
Constructor Details
This class inherits a constructor from ActionForm::Subform
Class Method Details
.add_delete_element ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/action_form/rails/subform.rb', line 23 def add_delete_element element :_destroy do input(type: :hidden, autocomplete: :off, value: "0") output(type: :bool) def render? object.persisted? || (object.is_a?(EasyParams::Base) && !object._destroy.nil?) end def detached? true end end end |
.add_primary_key_element ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/action_form/rails/subform.rb', line 10 def add_primary_key_element return if elements.key?(:id) element :id do input(type: :hidden, autocomplete: :off) output(type: :integer) def render? object.persisted? || (object.is_a?(EasyParams::Base) && !object.id.nil?) end end end |
Instance Method Details
#html_class ⇒ Object
39 40 41 |
# File 'lib/action_form/rails/subform.rb', line 39 def html_class object.id.nil? ? "new_#{name}" : super end |