我有一个用simple_form创建的Rails表单,如下所示:
= simple_form_for @new_biz, url: new_business_post_path, html: {:class => "customForm1", :method => "post"} do |f|
= f.input :business_name, label: false, :input_html => {:value => @wat.business_name, :readonly => true}
= f.input :wat_id, :as => :hidden, :input_html => {:value => @wat.id}
= f.input :first_name
= f.input :last_name
= f.input :email
= f.input :phone, :label => "Phone number"
= f.label "Personal Message"
= f.text_area :message, label: false
= f.submit "Submit"
验证:
validates :first_name, presence: {:message => "Please enter the first name."}
validates :last_name, presence: {:message => "Please enter the last name."}
validates :phone, presence: {:message => "Please enter the phone number"}
validates :message, presence: {:message => "Please enter a personal message"}
除text_area字段外,所有验证均按预期显示。我似乎无法找到遇到此问题的其他人。非常感谢所有建议,谢谢。
答案 0 :(得分:4)
不应将您的文本字段输入写为:
= f.input :message, as: :text, label: false