Class: Cms::FormEntriesController
Defined Under Namespace
Classes: FauxContentType
Instance Method Summary
collapse
#handle_access_denied_on_page, #handle_draft_not_found, #handle_not_found_on_page, #handle_server_error_on_page, #show_content_as_page
allow_guests_to
#no_browser_caching
Instance Method Details
#bulk_update ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'app/controllers/cms/form_entries_controller.rb', line 35
def bulk_update
ids = params[:content_id] || []
models = ids.collect do |id|
FormEntry.find(id.to_i)
end
if params[:commit] == 'Delete'
deleted = models.select do |m|
m.destroy
end
flash[:notice] = "Deleted #{deleted.size} records."
end
redirect_to entries_path(params[:form_id])
end
|
#create ⇒ Object
88
89
90
91
92
93
94
95
|
# File 'app/controllers/cms/form_entries_controller.rb', line 88
def create
find_form_and_populate_entry
if @entry.save
redirect_to entries_path(@form)
else
save_entry_failure
end
end
|
#edit ⇒ Object
67
68
69
|
# File 'app/controllers/cms/form_entries_controller.rb', line 67
def edit
@entry = Cms::FormEntry.find(params[:id])
end
|
#index ⇒ Object
Same behavior as ContentBlockController#index
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'app/controllers/cms/form_entries_controller.rb', line 53
def index
@form = Cms::Form.where(id: params[:id]).first
@content_type = FauxContentType.new(@form)
@search_filter = SearchFilter.build(params[:search_filter], Cms::FormEntry)
@blocks = Cms::FormEntry.where(form_id: params[:id]).search(@search_filter.term).paginate({page: params[:page], order: params[:order]})
@entry = Cms::FormEntry.for(@form)
@total_number_of_items = @blocks.size
end
|
#new ⇒ Object
84
85
86
|
# File 'app/controllers/cms/form_entries_controller.rb', line 84
def new
@entry = Cms::FormEntry.for(Form.find(params[:form_id]))
end
|
#save_entry_failure ⇒ Object
97
98
99
|
# File 'app/controllers/cms/form_entries_controller.rb', line 97
def save_entry_failure
render :new
end
|
#show ⇒ Object
80
81
82
|
# File 'app/controllers/cms/form_entries_controller.rb', line 80
def show
@entry = Cms::FormEntry.find(params[:id])
end
|
#submit ⇒ Object
Handles public submission of a form.
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'app/controllers/cms/form_entries_controller.rb', line 12
def submit
find_form_and_populate_entry
if @entry.save
if @form.show_text?
show_content_as_page(@form)
render layout: Cms::Form.layout
else
redirect_to @form.confirmation_redirect
end
unless @form.notification_email.blank?
Cms::EmailMessage.create!(
:recipients => @form.notification_email,
:subject => "[CMS Form] A new entry has been created",
:body => "A visitor has filled out the #{@form.name} form. The entry can be found here:
#{Cms::EmailMessage.absolute_cms_url(cms.form_entry_path(@entry)) }"
)
end
else
show_content_as_page(@form)
render 'error', layout: Cms::Form.layout
end
end
|
#update ⇒ Object
71
72
73
74
75
76
77
78
|
# File 'app/controllers/cms/form_entries_controller.rb', line 71
def update
@entry = Cms::FormEntry.find(params[:id]).enable_validations
if @entry.update(entry_params(@entry))
redirect_to form_entry_path(@entry)
else
render :edit
end
end
|