Skip to content

Class specific atoms

Petr Marek edited this page Aug 20, 2021 · 1 revision

Add VALID_PLACEMENT_TYPES definition to your atom to restrict the possible placement types. It validates as well as hides menu entries in the console selection menu when needed.

This is useful for one-of types of atoms such as a homepage slider or for types which only make sense given the right model (i.e. related items for an Item model).

class MyProject::Items::RelatedItems < Folio::Atom::Base
  ... 

  VALID_PLACEMENT_TYPES = %w[
    MyProject::Item
  ]

  ...
end

Default inherited from Folio::Atom::Base is nil, which skips the validation.