Sha256: da7532d961e4c49d471d2d95452aea7f257493f6c63c4731e1ae9eea89b39cd0
Contents?: true
Size: 1.01 KB
Versions: 2
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true module Decidim module Admin # A form object used to create categories from the admin dashboard. # class CategoryForm < Form include TranslatableAttributes translatable_attribute :name, String translatable_attribute :description, String attribute :parent_id, Integer mimic :category validates :name, :description, translatable_presence: true validates :current_process, presence: true validates :parent_id, inclusion: { in: :parent_categories_ids }, allow_blank: true attr_reader :current_process def initialize(attributes = {}) @current_process = attributes.delete("current_process") || attributes.delete(:current_process) super end def parent_categories @parent_categories ||= current_process.categories.first_class.where.not(id: id) end private def parent_categories_ids @parent_categories_ids ||= parent_categories.pluck(:id) end end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
decidim-admin-0.0.1 | app/forms/decidim/admin/category_form.rb |
decidim-0.0.1 | decidim-admin/app/forms/decidim/admin/category_form.rb |