Class: Tramway::Event::ParticipantExtendedFormCreator
- Inherits:
-
Core::FormCreator
- Object
- Core::FormCreator
- Tramway::Event::ParticipantExtendedFormCreator
- Defined in:
- app/forms/tramway/event/participant_extended_form_creator.rb
Class Method Summary collapse
Class Method Details
.build_validations(field) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'app/forms/tramway/event/participant_extended_form_creator.rb', line 19 def self.build_validations(field) case field.field_type when 'checkbox' field.validations.except('presence').deep_merge! inclusion: { in: ['true'] } else field.validations end end |
.create_form_class(uuid, event, **simple_properties) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/forms/tramway/event/participant_extended_form_creator.rb', line 4 def self.create_form_class(uuid, event, **simple_properties) class_name = "ParticipantExtendedForm#{uuid.gsub('-', '')}" properties = event.participant_form_fields.inputs_list.reduce({}) do |hash, field| hash.merge! field.title.to_sym => { object: field, validates: build_validations(field) } end if simple_properties.keys.any? ::Tramway::Core::ExtendableForm.new(class_name, simple_properties: simple_properties, **properties) else ::Tramway::Core::ExtendableForm.new(class_name, **properties) end end |