Reputation: 1239
I have a simple_field and I pass an object to a partial file. I do this in the partial :
<%= f.input :address,
:as => :hidden,
:label => "Address :",
:input_html=>{
:required => false,
:class => "address"
} %>
I want to use :as => hidden
depending on a certain condition. I mean the field should be hidden if a condition is true. Is that possible to do?
Upvotes: 0
Views: 90
Reputation: 5037
You could make your options hash separately and then add the hidden parameter if necessary
options = {
:label => "Address :",
:input_html=>{
:required => false,
:class => "address"
}
}
if condition_is_true? then options[:as] = "hidden" end
<%= f.input :address, options %>
Upvotes: 1