Finally found a nice date chooser script
(http://projects.exactlyoneturtle.com/date_picker), but am a little
confused how to implement it.
So I put this where I need the date picker:
<a id="_name_link" href="#"
onclick="DatePicker.toggleDatePicker(''name'')"
class="demo_link">[ choose date ]</a>
<div id="_name_calendar" class="date_picker"
style="display:none"></div>
And the field that receives the value is:
<input id="name" name="name" value=""
size="10"/></label>
But where do I put the following files?
date_picker_helper.rb
date-picker.css
date-picker.js
And where do I reference these? I''m using a std _form.html partial for
new and edit.
thx
n.
--
Posted via http://www.ruby-forum.com/.
On Fri, 2006-04-28 at 14:57 +0200, Nick Coyne wrote:> Finally found a nice date chooser script > (http://projects.exactlyoneturtle.com/date_picker), but am a little > confused how to implement it. > > So I put this where I need the date picker: > <a id="_name_link" href="#" > onclick="DatePicker.toggleDatePicker(''name'')" > class="demo_link">[ choose date ]</a> > <div id="_name_calendar" class="date_picker" > style="display:none"></div> > > And the field that receives the value is: > <input id="name" name="name" value="" size="10"/></label> > > But where do I put the following files? > date_picker_helper.rb---- app/helpers ----> date-picker.css---- public/stylesheets ----> date-picker.js---- public/javascripts> > And where do I reference these? I''m using a std _form.html partial for > new and edit.---- the javascript should be referenced in the html header (generally in the layout file), the helper should be automatic. Craig
Ok, works perfectly in the page, but how do I get it to insert the value
into the db. I simply replaced the existing
<%= date_select ''timelog'', ''worked_on'',
:class => ''field'' %>
with
<a id="_worked_on_link" href="#"
onclick="DatePicker.toggleDatePicker(''worked_on'')"
class="">[ choose
date ]</a>
<div id="_worked_on_calendar" class="date_picker"
style="display:none"></div>
<input type="hidden" id="worked_on"
name="worked_on" value=""
size="10"/>
but I get an error thrown indicating "Mysql::Error: Column
''worked_on''
cannot be null"
These are the request parameters:
Parameters: {"commit"=>"Create",
"task"=>{"percent_complete"=>"90",
"id"=>"9"},
"timelog"=>{"task_id"=>"0",
"hours"=>"1",
"comment"=>"test"},
"worked_on"=>"2006-4-26"}
So the date is there. What''s happening??
Then another question - how do I display today''s date on the page
(i''ll
put that instead of the [ choose date ] link.
thx
n.
Craig White wrote:> On Fri, 2006-04-28 at 14:57 +0200, Nick Coyne wrote:
>>
>> And the field that receives the value is:
>> <input id="name" name="name" value=""
size="10"/></label>
>>
>> But where do I put the following files?
>> date_picker_helper.rb
> ----
> app/helpers
> ----
>> date-picker.css
> ----
> public/stylesheets
> ----
>> date-picker.js
> ----
> public/javascripts
>>
>> And where do I reference these? I''m using a std _form.html
partial for
>> new and edit.
> ----
> the javascript should be referenced in the html header (generally in the
> layout file), the helper should be automatic.
>
> Craig
--
Posted via http://www.ruby-forum.com/.
duh, the field name should have been timelog[worked_on]. Works perfectly now. Just need to display today''s date now? thx n. Nick Coyne wrote:> Ok, works perfectly in the page, but how do I get it to insert the value > into the db. I simply replaced the existing > <%= date_select ''timelog'', ''worked_on'', :class => ''field'' %> > > with > > <a id="_worked_on_link" href="#" > onclick="DatePicker.toggleDatePicker(''worked_on'')" class="">[ choose > date ]</a> > <div id="_worked_on_calendar" class="date_picker" > style="display:none"></div> > <input type="hidden" id="worked_on" name="worked_on" value="" > size="10"/> > > but I get an error thrown indicating "Mysql::Error: Column ''worked_on'' > cannot be null" > > These are the request parameters: > Parameters: {"commit"=>"Create", "task"=>{"percent_complete"=>"90", > "id"=>"9"}, "timelog"=>{"task_id"=>"0", "hours"=>"1", > "comment"=>"test"}, "worked_on"=>"2006-4-26"} > > So the date is there. What''s happening?? > > Then another question - how do I display today''s date on the page (i''ll > put that instead of the [ choose date ] link. > > thx > n.-- Posted via http://www.ruby-forum.com/.
Fix that with controller code...assign timelog.worked_on = Date.today On Fri, 2006-04-28 at 15:43 +0200, Nick Coyne wrote:> duh, the field name should have been timelog[worked_on]. Works perfectly > now. > > Just need to display today''s date now? > > thx > n. > > Nick Coyne wrote: > > Ok, works perfectly in the page, but how do I get it to insert the value > > into the db. I simply replaced the existing > > <%= date_select ''timelog'', ''worked_on'', :class => ''field'' %> > > > > with > > > > <a id="_worked_on_link" href="#" > > onclick="DatePicker.toggleDatePicker(''worked_on'')" class="">[ choose > > date ]</a> > > <div id="_worked_on_calendar" class="date_picker" > > style="display:none"></div> > > <input type="hidden" id="worked_on" name="worked_on" value="" > > size="10"/> > > > > but I get an error thrown indicating "Mysql::Error: Column ''worked_on'' > > cannot be null" > > > > These are the request parameters: > > Parameters: {"commit"=>"Create", "task"=>{"percent_complete"=>"90", > > "id"=>"9"}, "timelog"=>{"task_id"=>"0", "hours"=>"1", > > "comment"=>"test"}, "worked_on"=>"2006-4-26"} > > > > So the date is there. What''s happening?? > > > > Then another question - how do I display today''s date on the page (i''ll > > put that instead of the [ choose date ] link. > > > > thx > > n. >
Craig White wrote:> Fix that with controller code...assign timelog.worked_on = Date.todayCool, all working nicely now - In my controller: @timelog.worked_on = Date.today In my view: <a id="_timelog[worked_on]_link" href="javascript:;" onclick="DatePicker.toggleDatePicker(''timelog[worked_on]'')" class=""><%=Date.today.to_s(format = :my_format_1)%></a> <div id="_timelog[worked_on]_calendar" class="date_picker" style="display:none"></div> <input type="hidden" id="timelog[worked_on]" name="timelog[worked_on]" value="<%=@timelog.worked_on%>" size="10"/> And in environment.rb, to make the rails displayed date format the same as the format the date picker uses: ActiveSupport::CoreExtensions::Date::Conversions::DATE_FORMATS.merge!( :my_format_1 => ''%d %b %Y'' ) Thanks Craig. n. -- Posted via http://www.ruby-forum.com/.