Experiment with a simple form builder

This commit is contained in:
bumi 2020-04-09 14:15:19 +02:00
parent d485b1e62e
commit fd9eddedfc
3 changed files with 13 additions and 27 deletions

View File

@ -25,10 +25,8 @@ class FormsController < ApplicationController
end
end
if Rails.env.development?
def form
@form = Form.find_by!(token: params[:id])
end
def form
@form = Form.find_by!(token: params[:id])
end
private

View File

@ -1,22 +1,12 @@
<h1><%= @form.title %></h1>
<p>
<%= link_to 'Google spreadsheet', @form.google_spreadsheet_url %>
</p>
<form method="post" action="<%= submission_url(@form) %>" enctype="multipart/form-data">
<p>
<label>Text</label>
<input type="text" name="text">
</p>
<p>
<label>Array</label>
<input type="checkbox" name="array[]" value="1">
<input type="checkbox" name="array[]" value="2">
<input type="checkbox" name="array[]" value="3">
</p>
<p>
<label>File</label>
<input type="file" name="file">
</p>
<input type="submit" value="senden">
</form>
<%= form_with url: submission_url(@form), action: 'post', authenticity_token: false, local: true, html: { enctype: 'multipart/form-data' } do %>
<% @form.header_values.each do |header| %>
<p>
<label><%= header %>
<%= text_field_tag header %>
</p>
<% end %>
<%= submit_tag 'Send', name: nil %>
<% end %>

View File

@ -2,9 +2,7 @@ Rails.application.routes.draw do
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
resources :forms do
if Rails.env.development?
member { get :form }
end
member { get :form }
resources :submissions
end
# short link for submission file uploads