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-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 {
|
.bg-red-100 {
|
||||||
--tw-bg-opacity: 1;
|
--tw-bg-opacity: 1;
|
||||||
background-color: rgb(254 226 226 / var(--tw-bg-opacity));
|
background-color: rgb(254 226 226 / var(--tw-bg-opacity));
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
module Merged
|
module Merged
|
||||||
class FormController < MergedController
|
class FormController < ::ApplicationController
|
||||||
|
|
||||||
def sendit
|
def post
|
||||||
@section = Section.find( params[:section_id] )
|
@section = Section.find( params[:section_id] )
|
||||||
@errors = { }
|
@errors = { }
|
||||||
return if bot_alert
|
return if bot_alert
|
||||||
check_maths
|
check_maths
|
||||||
verify_data
|
verify_data
|
||||||
if( @errors.length > 0)
|
if( @errors.length > 0)
|
||||||
render :form
|
render "merged/form/form"
|
||||||
else
|
else
|
||||||
dispatch_form_data( )
|
dispatch_form_data( )
|
||||||
redirect_to main_app.root_url , notice: @section.option("ok_message")
|
redirect_to main_app.root_url , notice: @section.option("ok_message")
|
||||||
@ -36,7 +36,6 @@ module Merged
|
|||||||
end
|
end
|
||||||
def check_option(card , value)
|
def check_option(card , value)
|
||||||
return unless value.blank?
|
return unless value.blank?
|
||||||
puts "Checking #{card.header} #{value}"
|
|
||||||
compulsory = card.option("compulsory") != "no"
|
compulsory = card.option("compulsory") != "no"
|
||||||
return unless compulsory
|
return unless compulsory
|
||||||
# check different types
|
# check different types
|
||||||
@ -48,7 +47,7 @@ module Merged
|
|||||||
def check_maths
|
def check_maths
|
||||||
key = params[:bot_fudder].to_i / 2
|
key = params[:bot_fudder].to_i / 2
|
||||||
if( (2*key + 1).to_s != params[:challenge])
|
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
|
||||||
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}"
|
raise "Type mismatch #{key} #{@attributes[key].class}!=#{value.class}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
puts "setting #{key}=#{value}"
|
|
||||||
attributes[key] = value
|
attributes[key] = value
|
||||||
end
|
end
|
||||||
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)
|
= markdown(section)
|
||||||
.flex.items-center.justify-start.m-10.md:m-20
|
.flex.items-center.justify-start.m-10.md:m-20
|
||||||
.mx-auto.w-full.max-w-4xl{class: "max-w-[50%]"}
|
.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)
|
- challenge = rand(8)
|
||||||
= hidden_field_tag :section_id , section.id
|
= hidden_field_tag :section_id , section.id
|
||||||
= hidden_field_tag :bot_fudder , "#{challenge*2}"
|
= hidden_field_tag :bot_fudder , "#{challenge*2}"
|
||||||
|
Loading…
Reference in New Issue
Block a user