Thank you very much for quick response. I gocha check my spelling more carefully next time ;) (I just wish the mispell like this could show up when I use check syntax command...) Now I finished the list action and things work well. On the other hand I notice one thing I ''m not sure if it is a problem or not: when user press new and action create is started(based on the scaffold template) I used some form helper,, and the code is <%= error_messages_for ''work_time'' %> <!--[form:work_time]--> <p><label for="work_time_check_in">Check in</label><br/> <%=datetime_select(''work_time'', ''check_in'')%></p> <p><label for="work_time_check_out">Check out</label><br/> <%=datetime_select(''work_time'', ''check_out'')%></p> <!--[eoform:work_time]--> when I look at browser and views the source code. it''s like the one below. Could someone tell me where is that (1i), (2i)...come from?does that '' i'' matter? <!--[form:work_time]--> <p><label for="work_time_check_in">Check in</label><br/> <select name="work_time[check_in(1i)]"> <option value="2000">2000</option> <option value="2001">2001</option> <option value="2002">2002</option> <option value="2003">2003</option> <option value="2004">2004</option> <option value="2005" selected="selected">2005</option> <option value="2006">2006</option> <option value="2007">2007</option> <option value="2008">2008</option> <option value="2009">2009</option> <option value="2010">2010</option> </select> <select name="work_time[check_in(2i)]"> <option value="1">January</option> <option value="2">February</option> <option value="3">March</option> ... Thank you. sammy --------------------------------- DO YOU YAHOO!? 雅虎免费G邮箱-中国第一绝无垃圾邮件骚扰超大邮箱 _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Craig Davey
2005-Aug-23 19:29 UTC
Re: Re: Newbie question: mysterious i afer using formhelper
Hi Sammy> when I look at browser and views the source code. it''s like the one below. > Could someone tell me where is that (1i), (2i)...come from?does that '' i'' > matter? > > <!--[form:work_time]--> > <p><label for="work_time_check_in">Check in</label><br/> > <select name="work_time[check_in(1i)]"> > <option value="2000">2000</option> > <option value="2001">2001</option>The 1i, 2i, 3i etc that you see are indexes created by the datetime_select method so that each component of the submitted date can be seperated and parsed appropriately. It''s simply a rails format so that dates can be handled more conveniently, definitely nothing to worry about. The indexes break down like this: 1i = Index #1 = Year 2i = Index #2 = Month 3i = Index #3 = Day of the month 4i = Index #4 = Hour 5i = Index #5 = Minute 6i = Index #6 = Second So if you wanted to grab only the year from a date submitted by a datetime_select you could do: year = @params[''object''][''date(1i)''] Of course, it''s often easier to rely on the magick of ActiveRecord to automatically parse a date object from each indexed value as would happen if you wrote: object.attributes = @params[''object''] Craig Davey