commit
c0064934e9
@ -25,6 +25,19 @@ class FormsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def edit
|
||||||
|
@form = current_user.forms.find_by!(token: params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
@form = current_user.forms.find_by!(token: params[:id])
|
||||||
|
if @form.update(form_params)
|
||||||
|
redirect_to form_url(@form)
|
||||||
|
else
|
||||||
|
render :edit
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def form
|
def form
|
||||||
@form = Form.find_by!(token: params[:id])
|
@form = Form.find_by!(token: params[:id])
|
||||||
end
|
end
|
||||||
|
15
app/views/forms/_form.html.erb
Normal file
15
app/views/forms/_form.html.erb
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<%= form_for form, local: true do |f| %>
|
||||||
|
<div class="field">
|
||||||
|
<div class="control">
|
||||||
|
<%= f.text_field :title, class: 'input', placeholder: 'Title' %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<div class="control">
|
||||||
|
<%= f.text_field :thank_you_url, class: 'input', placeholder: 'Thank you url' %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<%= f.submit class: 'button is-primary' %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
14
app/views/forms/edit.html.erb
Normal file
14
app/views/forms/edit.html.erb
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<div class="section">
|
||||||
|
<div class=" columns ">
|
||||||
|
<div class="column is-half is-offset-one-quarter">
|
||||||
|
<div class="box">
|
||||||
|
<div class="content has-text-centered">
|
||||||
|
<h1 class="has-text-weight-light">Update <%= @form.title %></h1>
|
||||||
|
|
||||||
|
<%= render 'form', form: @form %>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -4,21 +4,9 @@
|
|||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="content has-text-centered">
|
<div class="content has-text-centered">
|
||||||
<h1 class="has-text-weight-light">Create a new form</h1>
|
<h1 class="has-text-weight-light">Create a new form</h1>
|
||||||
<%= form_for @form do |f| %>
|
|
||||||
<div class="field">
|
<%= render 'form', form: @form %>
|
||||||
<div class="control">
|
|
||||||
<%= f.text_field :title, class: 'input', placeholder: 'Title' %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="field">
|
|
||||||
<div class="control">
|
|
||||||
<%= f.text_field :thank_you_url, class: 'input', placeholder: 'Thank you url' %>
|
|
||||||
</div>
|
|
||||||
</div><br>
|
|
||||||
<div>
|
|
||||||
<%= f.submit class: 'button is-primary' %>
|
|
||||||
<% end %>
|
|
||||||
</divdiv>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user