Class: Decidim::Admin::AreaForm

Inherits:
Form show all
Includes:
TranslatableAttributes
Defined in:
decidim-admin/app/forms/decidim/admin/area_form.rb

Overview

A form object to create or update areas.

Constant Summary

Constants included from Decidim::AttributeObject::TypeMap

Decidim::AttributeObject::TypeMap::Boolean, Decidim::AttributeObject::TypeMap::Decimal

Instance Attribute Summary

Attributes inherited from Decidim::AttributeObject::Form

#context

Instance Method Summary collapse

Methods included from TranslatableAttributes

#default_locale?

Methods inherited from Decidim::AttributeObject::Form

ensure_hash, from_model, from_params, hash_from, infer_model_name, #map_model, mimic, mimicked_model_name, model_name, #persisted?, #to_key, #to_model, #to_param, #valid?, #with_context

Methods included from Decidim::AttributeObject::Model

#[], #[]=, #attributes, #attributes_with_values, #initialize, #to_h

Instance Method Details

#area_typeObject


29
30
31
# File 'decidim-admin/app/forms/decidim/admin/area_form.rb', line 29

def area_type
  Decidim::AreaType.find_by(id: area_type_id) if area_type_id
end

#name_uniquenessObject


20
21
22
23
24
25
# File 'decidim-admin/app/forms/decidim/admin/area_form.rb', line 20

def name_uniqueness
  return unless organization
  return unless organization.areas.where(name: name, area_type: area_type).where.not(id: id).any?

  errors.add(:name, :taken)
end