Class: Panda::CMS::Admin::FormsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/panda/cms/admin/forms_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#set_current_request_details

Methods included from Panda::CMS::ApplicationHelper

#active_link?, #block_link_to, #component, #level_indent, #menu_indent, #nav_class, #nav_highlight_colour_classes, #panda_cms_collection, #panda_cms_collection_items, #panda_cms_editor, #panda_cms_feature_enabled?, #panda_cms_form_with, #selected_nav_highlight_colour_classes, #table_indent, #title_tag

Instance Method Details

#indexObject

Lists all forms

Returns:

  • ActiveRecord::Collection A list of all forms



12
13
14
15
# File 'app/controllers/panda/cms/admin/forms_controller.rb', line 12

def index
  forms = Panda::CMS::Form.order(:name)
  render :index, locals: {forms: forms}
end

#showObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/panda/cms/admin/forms_controller.rb', line 17

def show
  form = Panda::CMS::Form.find(params[:id])

  add_breadcrumb form.name, admin_cms_form_path(form)
  submissions = form.form_submissions.order(created_at: :desc)
  # TODO: Set a whitelist of fields we allow to be submitted for the form, shown in this view
  # and a formatting array of how to display them... eventually?

  fields = if submissions.last
    submissions.last.data.keys.reverse.map { |field| [field, field.titleize] }
  else
    []
  end

  render :show, locals: {form: form, submissions: submissions, fields: fields}
end