Class: Para::Inputs::NestedManyInput
- Inherits:
-
NestedBaseInput
- Object
- SimpleForm::Inputs::Base
- NestedBaseInput
- Para::Inputs::NestedManyInput
- Defined in:
- lib/para/inputs/nested_many_input.rb
Constant Summary
Constants inherited from NestedBaseInput
Para::Inputs::NestedBaseInput::GLOBAL_NESTED_FIELD_KEY
Instance Attribute Summary collapse
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
Instance Method Summary collapse
Instance Attribute Details
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
4 5 6 |
# File 'lib/para/inputs/nested_many_input.rb', line 4 def resource @resource end |
Instance Method Details
#input(_wrapper_options = nil) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/para/inputs/nested_many_input.rb', line 6 def input( = nil) [:class] << 'nested-many' orderable = .fetch(:orderable, model.orderable?) = .fetch(:add_button, true) # Load existing resources resources = object.send(attribute_name) # Order them if the list should be orderable resources = resources.sort_by(&:position) if orderable locals = .fetch(:locals, {}) with_global_nested_field do template.render( partial: 'para/inputs/nested_many', locals: { form: @builder, model: model, attribute_name: attribute_name, orderable: orderable, add_button: , dom_identifier: dom_identifier, resources: resources, nested_locals: locals, subclass: subclass, subclasses: subclasses, add_button_label: , add_button_class: , allow_destroy_if: allow_destroy_if, inset: inset?, uncollapsed: uncollapsed?, render_partial: render_partial?, remote_partial_params: remote_partial_params } ) end end |