user2406618
user2406618

Reputation: 144

assign params value to text field tag

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

Answers (1)

Bachan Smruty
Bachan Smruty

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

Related Questions