Class: Admin::Tramway::Event::ParticipantFormFieldForm
- Inherits:
-
Tramway::Core::ExtendedApplicationForm
- Object
- Tramway::Core::ExtendedApplicationForm
- Admin::Tramway::Event::ParticipantFormFieldForm
- Defined in:
- app/forms/admin/tramway/event/participant_form_field_form.rb
Instance Method Summary collapse
-
#initialize(object) ⇒ ParticipantFormFieldForm
constructor
A new instance of ParticipantFormFieldForm.
- #list_field ⇒ Object
- #options ⇒ Object
- #options=(value) ⇒ Object
- #presence_field ⇒ Object
- #submit(params) ⇒ Object
Constructor Details
#initialize(object) ⇒ ParticipantFormFieldForm
Returns a new instance of ParticipantFormFieldForm.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/forms/admin/tramway/event/participant_form_field_form.rb', line 7 def initialize(object) super(object).tap do form_properties event: :association, title: :string, description: :string, field_type: :default, options: :text, list_field: :boolean, presence_field: :boolean, position: :numeric end end |
Instance Method Details
#list_field ⇒ Object
29 30 31 |
# File 'app/forms/admin/tramway/event/participant_form_field_form.rb', line 29 def list_field model.&.dig('list_field') == 'true' end |
#options ⇒ Object
37 38 39 |
# File 'app/forms/admin/tramway/event/participant_form_field_form.rb', line 37 def model.&.to_json end |
#options=(value) ⇒ Object
41 42 43 |
# File 'app/forms/admin/tramway/event/participant_form_field_form.rb', line 41 def (value) super value == '' ? value : JSON.parse(value) end |
#presence_field ⇒ Object
33 34 35 |
# File 'app/forms/admin/tramway/event/participant_form_field_form.rb', line 33 def presence_field model.&.dig('validations', 'presence') == 'true' end |
#submit(params) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'app/forms/admin/tramway/event/participant_form_field_form.rb', line 20 def submit(params) super(params).tap do model. = {} if model. == '' model.&.merge! list_field: (params[:list_field] == '1').to_s model.&.deep_merge! validations: { presence: (params[:presence_field] == '1').to_s } model.save end end |