Reputation: 144
How can i assign a params value(date from params) to my text_field_tag for search form
In my form tag which has a text_field_tag as follows:
<%= text_field_tag 'date_from', Date.today.prev_month.at_beginning_of_month, :size => 10, :id => 'dis_date_from' %><%= calendar_for('dis_date_from') %>
I have assigned a default value to this tag
How could we possibly assign params value to this text_field_tag if a value(date) is not nil in params.
Thanks in advance.
Upvotes: 0
Views: 1433
Reputation: 5734
Try with
<%= text_field_tag 'date_from', params['date_form'] || Date.today.prev_month.at_beginning_of_month, :size => 10, :id => 'dis_date_from' %><%= calendar_for('dis_date_from') %>
Upvotes: 4