form_forで自動生成される<div class="field_with_error">を消す方法
formへの入力でバリデーションエラーがあると自動生成される。
生成される位置
<form>
<input type="hidden">
<input type="hidden">
<div class="field_with_error">
<input type="text">
</div>
//以下略
でこいつの厄介なところはレイアウトに影響してくるというところで、
これを
こんな風に崩してくる。
で対処法を調べていたら
config/application.rb
module ChatSpace
class Application < Rails::Application
config.generators do |g|
#中略
end
ここに
config/application.rb
module ChatSpace
class Application < Rails::Application
config.generators do |g|
#中略
config.action_view.field_error_proc = Proc.new { |html_tag, instance| html_tag }
end
これを記述すれば自動生成されなくなってレイアウト崩れも解決されます。
Author And Source
この問題について(form_forで自動生成される<div class="field_with_error">を消す方法), 我々は、より多くの情報をここで見つけました https://qiita.com/hideo_taniguchi/items/95900a044034e463d90e著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .