Class: Decidim::Templates::Admin::ProposalAnswerTemplateForm
- Inherits:
-
TemplateForm
- Object
- AttributeObject::Form
- Form
- TemplateForm
- Decidim::Templates::Admin::ProposalAnswerTemplateForm
- Defined in:
- decidim-templates/app/forms/decidim/templates/admin/proposal_answer_template_form.rb
Constant Summary
Constants included from AttributeObject::TypeMap
AttributeObject::TypeMap::Boolean, AttributeObject::TypeMap::Decimal
Instance Attribute Summary
Attributes inherited from AttributeObject::Form
Instance Method Summary collapse
- #component_has_been_selected ⇒ Object
- #map_model(model) ⇒ Object
- #proposal_state_id_is_valid ⇒ Object
- #skip_name_validation ⇒ Object
Methods included from Decidim::TranslatableAttributes
#attachment?, #default_locale?
Methods inherited from AttributeObject::Form
ensure_hash, from_model, from_params, hash_from, infer_model_name, mimic, mimicked_model_name, model_name, #persisted?, #to_key, #to_model, #to_param, #valid?, #with_context
Methods included from AttributeObject::Model
#[], #[]=, #attributes, #attributes_with_values, #initialize, #to_h
Instance Method Details
#component_has_been_selected ⇒ Object
30 31 32 |
# File 'decidim-templates/app/forms/decidim/templates/admin/proposal_answer_template_form.rb', line 30 def component_has_been_selected errors.add(:select_component, :blank) if select_component end |
#map_model(model) ⇒ Object
14 15 16 17 |
# File 'decidim-templates/app/forms/decidim/templates/admin/proposal_answer_template_form.rb', line 14 def map_model(model) self.proposal_state_id = model.field_values["proposal_state_id"]&.to_i self.component_constraint = model.templatable&.id end |
#proposal_state_id_is_valid ⇒ Object
23 24 25 26 27 28 |
# File 'decidim-templates/app/forms/decidim/templates/admin/proposal_answer_template_form.rb', line 23 def proposal_state_id_is_valid if Decidim::Proposals::ProposalState.where(decidim_component_id: component_constraint).find_by(id: proposal_state_id).blank? errors.add(:proposal_state_id, :blank) end end |
#skip_name_validation ⇒ Object
19 20 21 |
# File 'decidim-templates/app/forms/decidim/templates/admin/proposal_answer_template_form.rb', line 19 def skip_name_validation select_component end |