fixing the forms again
This commit is contained in:
parent
6852883273
commit
accb668267
@ -2079,6 +2079,11 @@ select {
|
||||
border-color: rgb(156 163 175 / var(--tw-border-opacity));
|
||||
}
|
||||
|
||||
.border-green-500 {
|
||||
--tw-border-opacity: 1;
|
||||
border-color: rgb(34 197 94 / var(--tw-border-opacity));
|
||||
}
|
||||
|
||||
.bg-red-100 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(254 226 226 / var(--tw-bg-opacity));
|
||||
|
@ -1,14 +1,14 @@
|
||||
module Merged
|
||||
class FormController < MergedController
|
||||
class FormController < ::ApplicationController
|
||||
|
||||
def sendit
|
||||
def post
|
||||
@section = Section.find( params[:section_id] )
|
||||
@errors = { }
|
||||
return if bot_alert
|
||||
check_maths
|
||||
verify_data
|
||||
if( @errors.length > 0)
|
||||
render :form
|
||||
render "merged/form/form"
|
||||
else
|
||||
dispatch_form_data( )
|
||||
redirect_to main_app.root_url , notice: @section.option("ok_message")
|
||||
@ -36,7 +36,6 @@ module Merged
|
||||
end
|
||||
def check_option(card , value)
|
||||
return unless value.blank?
|
||||
puts "Checking #{card.header} #{value}"
|
||||
compulsory = card.option("compulsory") != "no"
|
||||
return unless compulsory
|
||||
# check different types
|
||||
@ -48,7 +47,7 @@ module Merged
|
||||
def check_maths
|
||||
key = params[:bot_fudder].to_i / 2
|
||||
if( (2*key + 1).to_s != params[:challenge])
|
||||
@errors[:challenge] = "Check the maths #{params[:challenge]}"
|
||||
@errors[:challenge] = "Check the anti bot maths, it wasn't: #{params[:challenge]}"
|
||||
end
|
||||
end
|
||||
|
||||
|
5
app/helpers/merged/form_helper.rb
Normal file
5
app/helpers/merged/form_helper.rb
Normal file
@ -0,0 +1,5 @@
|
||||
module Merged
|
||||
module FormHelper
|
||||
include ViewHelper
|
||||
end
|
||||
end
|
@ -69,7 +69,6 @@ module Merged
|
||||
raise "Type mismatch #{key} #{@attributes[key].class}!=#{value.class}"
|
||||
end
|
||||
end
|
||||
puts "setting #{key}=#{value}"
|
||||
attributes[key] = value
|
||||
end
|
||||
end
|
||||
|
8
app/views/merged/form/form.haml
Normal file
8
app/views/merged/form/form.haml
Normal file
@ -0,0 +1,8 @@
|
||||
.flex.flex-col.m-20
|
||||
.flex.items-center.justify-center.flex-1
|
||||
- @errors.each do |name , message|
|
||||
.m-5.rounded.border-l-4.border-green-500.bg-red-50.p-4
|
||||
%strong.font-medium.text-red-700= name.capitalize
|
||||
.mt-2.text-sm.text-red-700= message
|
||||
|
||||
= render_section @section
|
@ -6,7 +6,7 @@
|
||||
= markdown(section)
|
||||
.flex.items-center.justify-start.m-10.md:m-20
|
||||
.mx-auto.w-full.max-w-4xl{class: "max-w-[50%]"}
|
||||
= form_tag( merged.form_sendit_path , {class: "mt-10" }) do
|
||||
= form_tag( main_app.post_form_path , {class: "mt-10" }) do
|
||||
- challenge = rand(8)
|
||||
= hidden_field_tag :section_id , section.id
|
||||
= hidden_field_tag :bot_fudder , "#{challenge*2}"
|
||||
|
Loading…
Reference in New Issue
Block a user