Class: ActionForm::Rails::Base
- Inherits:
-
Base
- Object
- Base
- ActionForm::Rails::Base
show all
- Includes:
- Rendering
- Defined in:
- lib/action_form/rails/base.rb
Overview
RailsForm class for ActionForm that handles Rails-specific form rendering.
It integrates with Rails form helpers and provides a Rails-friendly interface
for building forms.
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Rendering
#render_authenticity_token, #render_form, #render_method_input, #render_submit, #render_utf8_input
Constructor Details
#initialize(model: nil, scope: self.class.scope, params: nil, **html_options) ⇒ Base
Returns a new instance of Base.
19
20
21
22
23
24
|
# File 'lib/action_form/rails/base.rb', line 19
def initialize(model: nil, scope: self.class.scope, params: nil, **html_options)
@namespaced_model = model
@object = model.is_a?(Array) ? Array(model).last : model
@scope = scope.nil? && @object.nil? ? nil : (scope || param_key)
super(object: @object, scope: @scope, params: params, **html_options)
end
|
Instance Attribute Details
#namespaced_model ⇒ Object
Returns the value of attribute namespaced_model.
17
18
19
|
# File 'lib/action_form/rails/base.rb', line 17
def namespaced_model
@namespaced_model
end
|
Class Method Details
.many(name, default: nil, &block) ⇒ Object
34
35
36
37
38
|
# File 'lib/action_form/rails/base.rb', line 34
def many(name, default: nil, &block)
super
elements[name].subform_definition.add_primary_key_element
elements[name].subform_definition.add_delete_element
end
|
.resource_model(model = nil) ⇒ Object
27
28
29
30
31
32
|
# File 'lib/action_form/rails/base.rb', line 27
def resource_model(model = nil)
return @resource_model unless model
@resource_model = model
@scope = model.model_name.param_key.to_sym
end
|
40
41
42
43
|
# File 'lib/action_form/rails/base.rb', line 40
def subform(name, default: nil, &block)
super
elements[name].add_primary_key_element
end
|
13
14
15
|
# File 'lib/action_form/rails/base.rb', line 13
def self.subform_class
ActionForm::Rails::Subform
end
|
Instance Method Details
#view_template ⇒ Object
46
47
48
49
50
51
|
# File 'lib/action_form/rails/base.rb', line 46
def view_template
render_form do
render_elements
render_submit
end
end
|