Sha256: 14f6bcc71ec2f9af8824e865f2946ff275a44d371227aa077153f42aa97730d4
Contents?: true
Size: 1.47 KB
Versions: 24
Compression:
Stored size: 1.47 KB
Contents
# frozen_string_literal: true module PandaCms module Admin class FormsController < ApplicationController before_action :set_initial_breadcrumb, only: %i[index show] # before_action :set_paper_trail_whodunnit, only: %i[create update] before_action :authenticate_admin_user! # Lists all forms # @type GET # @return ActiveRecord::Collection A list of all forms def index forms = PandaCms::Form.order(:name) render :index, locals: {forms: forms} end def show form = PandaCms::Form.find(params[:id]) add_breadcrumb form.name, admin_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 private def set_initial_breadcrumb add_breadcrumb "Forms", admin_forms_path end private # Only allow a list of trusted parameters through # @type private # @return ActionController::StrongParameters def form_params params.require(:form).permit(:name, :completion_path) end end end end
Version data entries
24 entries across 24 versions & 1 rubygems