Rails simple_form text_area 不显示错误
Rails simple_form text_area doesn't display errors
我用 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 字段外,所有验证均按预期显示。我似乎找不到其他遇到此问题的人。非常感谢所有建议,谢谢。
您的文本字段输入不应该写成:
= f.input :message, as: :text, label: false
?
我用 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 字段外,所有验证均按预期显示。我似乎找不到其他遇到此问题的人。非常感谢所有建议,谢谢。
您的文本字段输入不应该写成:
= f.input :message, as: :text, label: false
?