Adminpanel

View the Project on GitHub codn/adminpanel

Special Behavior

Modules

Generators

Module · Page models

A sample pages model looks like this, you need to add this page in your adminpanel_setup.

config.displayable_pages = [
  Adminpanel::AboutUsPage
]

Your model should look like this

module Adminpanel
  class AboutUsPage < Page
    def self.instance
      first || create!(name: 'Acerca de Nosotros', type: 'Adminpanel::AboutUsPage')
    end

    store :fields, accessors: [
      :title,
      :header,
      :body,
      :experience
    ]

    def self.form_attributes
      [
        {
          'title' => {
            'type' => 'text_field',
            'label' => 'Título'
          }
        },
        {
          'header'  => {
            'type' => 'text_field',
            'label' => 'Cabecera'
          }
        },
        {
          'body' => {
            'type' => 'wysiwyg_field',
            'label' => 'Cuerpo'
          }
        },
        {
          'experience'  => {
            'type' => 'text_field',
            'label' => 'Experiencia'
          }
        }
      ]
    end

    def self.display_name
      'Acerca de Nosotros'
    end

    def self.icon
      'home'
    end

  end
end