Formtastic validation not working - Rails -


i'm using formtastic in rails apps can't validation work on customer side front end. app has admin side using activeadmin (which uses formtastic - seems pick validations model no problem)

as last resort tried turn on html validation in formtastic initializer file

formtastic::formbuilder.perform_browser_validations = true

and added form attributes

:required => true

but did not seem work.

my form:

 <%= f.inputs %>   <%= f.input :forename, :label => "first name:", :required => "true" %>    <%= f.input :surname, :required => true, :label => "surname:" %>   <%= f.input :campus, :label => "campus:" ,:collection => ["college lane", "de havilland", "fielder centre", "maclaurin", "meridian house", "other"] %>   <%= f.input :job_course, :label => "job/course:" %>   <%= f.input :address, :label => "address:", :as => :text, :input_html => {:rows => 5} %>   <%= f.input :telephone, :label => "telephone:", :required => true %>   <%= f.input :email, :label => "email address:" %>   <%= f.input :uhcontact, :label => "uh contact:" %>    <%= f.input :department_id, :label => "sbu/department:",:collection => department.select(:id,:name) %>    <%= f.input :category_injured_person, :as => :check_boxes, :multiple => true, :label => "category of injured person:", :collection => ["maintenance","portering","security","student","technical","contractor (specify below)","visitor","other (specify below)"] %> 
  <%= f.action :submit, :as => :button, :label => "next:" %>    <% end %>    

model:

class accident < activerecord::base   belongs_to :department      validates :forename, :presence => true, presence: { message: "forename field required" }  validates :surname, :presence => true, presence: { message: "surname field required" }end 

controller:

@accident = accident.new(params.require(:accident).permit(:acc_ref, :injured, :forename, :email, :campus, :surname, :job_course, :address, :telephone, :uhcontact,:sbu, :department, :department_id, :dateadded, :time, :acad_year, :campusother, :place, :witness, :witness_contact, :additional_witness, :other_location, :locationaccident, :other_category, :other_contractor, :other_nature, :other_cause, :other_site, :timeawaywork, :timeawaydays, :timeawayhours, :description, :reporter_name, :position, :reporter_telephone, :reporter_email, :reporter_date, :follow_up_date, :followed_up, :discussed_manager, :accident_reportable, :action_taken, :other_comments, :status, :category_injured_person, :natureofinjury , :siteofinjury, :causeofinjury )) # @accident.save

if @accident.save

redirect_to form_path

else

flash[:alert] = 'fail.' redirect_to :action => :form end


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -