Class: ActionForm::Rails::Subform
- Inherits:
-
Subform
- Object
- Subform
- 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.
Class Method Summary collapse
Instance Method Summary collapse
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 |