我有一个带条件引导程序的表单:
= simple_form_for(@user) do |f|
= f.input :first_name
- if f.object.new_record?
%button.btn.btn-primary{"data-target" => "#accordion", "data-toggle" => "collapse", :type => "button"}
.fa.fa-cog
More options
#accordion.collapse
= f.input :many_more_fields
- else
= f.input :many_more_fields
是否有更好的方法使css有条件,而不必重复= f.input :many_more_fields
。
CSS部分:
%button.btn.btn-primary{"data-target" => "#accordion", "data-toggle" => "collapse", :type => "button"}
.fa.fa-cog
More options
#accordion.collapse
P.S。有什么想法,除了为= f.input :many_more_fields
创建局部视图?