<label for="event_start_date">Start date:</label> <%= date_select ''event'', ''start_date'' %> This results in following html: <select name="event[start_date(1i)]"> <option value="2000">2000</option> ..... <option value="2010">2010</option> </select> <select name="event[start_date(2i)]"> <option value="1">January</option> .... <option value="12">December</option> </select> .... I tried the following code (and some combinations) to get the year part of the date. start_day = params[:event][:start_date] But it doesn''t work. How do I get the individual values from the web? Thanks. -=- Neeraj _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
David Barrett
2005-Nov-22 12:22 UTC
Re: How to retrieve the individual value for a date field
Neeraj:
@day = params[:event][''start_date(3i)'']
@month = params[:event][''start_date(2i)'']
@year = params[:event][''state_date(1i)'']
This should work fine for getting the raw HTML. Of course, you can
also get it from the model of whatever it is... say the information is
going into the @events object, and start_date is the variable:
@event.start_date.mday, @event.start_date.month, @event.start_date.year
Hope this helps.
Dave
On 11/2/05, Neeraj Kumar
<neeraj.jsr-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> <label for="event_start_date">Start date:</label>
> <%= date_select ''event'',
''start_date'' %>
>
> This results in following html:
>
> <select name="event[start_date(1i)]">
> <option value="2000">2000</option>
> .....
> <option value="2010">2010</option>
> </select>
>
> <select name="event[start_date(2i)]">
> <option value="1">January</option>
> ....
> <option value="12">December</option>
> </select>
>
> ....
>
>
> I tried the following code (and some combinations) to get the year part of
> the date.
> start_day = params[:event][:start_date]
>
> But it doesn''t work. How do I get the individual values from the
web?
>
> Thanks.
> -=- Neeraj
>
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
>
>
--
Site: http://antidis.com/