2016-08-06 3 views
0

'option_groups_from_collection_for_select'에 include_blank 옵션을 포함 시키려고 여기에 문제가 있습니다. include_blank 옵션을 갖고 싶지만 현재 업데이트 된 값 대신 빈 값을 표시하고 싶습니다. 나는 이것을 여기에서 시도했다. 그러나 그것은 아직도 공백으로 보여준다.include_blank 옵션이있는 option_groups_from_collection_for_select

select_tag(:candidate_source, option_groups_from_collection_for_select(grouped_candidate_sources, :second, :first, :id, :source), { :include_blank => true, :selected => :source }) 

답변

0

option_groups_from_collection_for_select의 마지막 인수는 선택한 옵션이며 사용자의 값에 매핑해야합니다.

option_key_method (4 번째 arg)이 :id이므로 양식 객체를 인수로 직접 전달할 수 있습니다. 예 :

select_tag(:candidate_source, option_groups_from_collection_for_select(grouped_candidate_sources, :second, :first, :id, :source, f.object.source), { :include_blank => true } 

어쨌든, 더 인수 내용은 여기를 참조하십시오 http://apidock.com/rails/ActionView/Helpers/FormOptionsHelper/option_groups_from_collection_for_select