LoginSignup
0
0

More than 3 years have passed since last update.

simple_formのcollection_radio_buttonsのinclude_hiddenオプション

Posted at

simple_formのcollection_radio_buttonsで詰まったところがあったので記載。

環境

Rails 5.2.2
simple_form 4.1.0

詰まった時の状況

特定のレコードの状態の時に collection_radio_buttons で生成したradio buttonをdisableにしていた。
対象のカラムはint(modelでenum指定)でnot null

collection_radio_buttons で生成する際に

<input type="hidden" name="model_name[column_name]" value="">

も一緒に生成され、対応するカラムのparamがblankでpostされてしまった。

対応

include_hidden: false をオプションとして渡す

<%= f.collection_radio_buttons :column_name, ~~, include_hidden: false %>

Readme等に記載見当たらずなかなかたどり着けなかった。。。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0