Sha256: 02b0f3483cea1fe76d803a0c7e758169d119d52a449a4bedd067a9898cd847e9

Contents?: true

Size: 720 Bytes

Versions: 15

Compression:

Stored size: 720 Bytes

Contents

# frozen_string_literal: true
module Decidim
  module Admin
    # A form object to create or update pages.
    class StaticPageForm < Form
      include TranslatableAttributes

      attribute :slug, String
      translatable_attribute :title, String
      translatable_attribute :content, String

      mimic :static_page

      validates :slug, presence: true
      validates :title, :content, translatable_presence: true
      validate :slug, :slug_uniqueness

      alias organization current_organization

      private

      def slug_uniqueness
        return unless organization && organization.static_pages.where(slug: slug).where.not(id: id).any?

        errors.add(:slug, :taken)
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
decidim-admin-0.1.0 app/forms/decidim/admin/static_page_form.rb
decidim-0.1.0 decidim-admin/app/forms/decidim/admin/static_page_form.rb
decidim-admin-0.0.8.1 app/forms/decidim/admin/static_page_form.rb
decidim-0.0.8.1 decidim-admin/app/forms/decidim/admin/static_page_form.rb
decidim-admin-0.0.7 app/forms/decidim/admin/static_page_form.rb
decidim-0.0.7 decidim-admin/app/forms/decidim/admin/static_page_form.rb
decidim-admin-0.0.6 app/forms/decidim/admin/static_page_form.rb
decidim-0.0.6 decidim-admin/app/forms/decidim/admin/static_page_form.rb
decidim-admin-0.0.5 app/forms/decidim/admin/static_page_form.rb
decidim-0.0.5 decidim-admin/app/forms/decidim/admin/static_page_form.rb
decidim-0.0.4 decidim-admin/app/forms/decidim/admin/static_page_form.rb
decidim-admin-0.0.3 app/forms/decidim/admin/static_page_form.rb
decidim-0.0.3 decidim-admin/app/forms/decidim/admin/static_page_form.rb
decidim-admin-0.0.2 app/forms/decidim/admin/static_page_form.rb
decidim-0.0.2 decidim-admin/app/forms/decidim/admin/static_page_form.rb