Customizing the calendar - Calendar Date Select Bridge

7 views
Skip to first unread message

mow...@googlemail.com

unread,
Jul 22, 2008, 5:42:41 AM7/22/08
to ActiveScaffold : Ruby on Rails plugin
Hej there,


I try to customize the calendar through its options hash, which
unfortunately doesn't work (I installed the calendardateselect
plugin):


config.columns[:date].options = { :year_range => 3.years.ago..
0.years.ago }


Am I missing something?


Thanks alot,
Mowsen

Ed W

unread,
Jul 22, 2008, 5:47:21 AM7/22/08
to actives...@googlegroups.com

Everyone needs to start quoting versions of code and rails right now -
there are some big changes in versions ...

To be honest - crack open the code and have a look - it's reasonably
simple to follow once you stare at if for half an hour

Good luck

Ed

mow...@googlemail.com

unread,
Jul 22, 2008, 7:26:50 AM7/22/08
to ActiveScaffold : Ruby on Rails plugin
> Everyone needs to start quoting versions of code and rails right now -
> there are some big changes in versions ...
>
> To be honest - crack open the code and have a look - it's reasonably
> simple to follow once you stare at if for half an hour

Hej Ed

thanks for the quick reply. I'm running rails 2.1.0 and latest
activescaffold. I had a look into the code but I don't really
understand what's going on because I'm quite new to ruby and rails. So
i assume that the options have to be given to the calendar while
creating it and can't be changed afterwards through
config.columns[:date].options. I'm not sure though, how it's possible
to give additional options to the config.columns[:date].form_ui
= :calendar_date_select statement.

Lightning Dave Bolton

unread,
Jul 23, 2008, 7:31:40 PM7/23/08
to ActiveScaffold : Ruby on Rails plugin, mow...@googlemail.com
On Jul 22, 9:26 pm, "mow...@googlemail.com" <mow...@googlemail.com>
wrote:
> i assume that the options have to be given to the calendar while
> creating it and can't be changed afterwards through
> config.columns[:date].options. I'm not sure though, how it's possible
> to give additional options to the config.columns[:date].form_ui
> = :calendar_date_select statement.

Okay, I did this just yesterday, so you're in luck.

- AS doesn't pass through the column options you set, as you've
already identified.
- Behind the scenes, AS ends up calling a method called
active_scaffold_input_calendar_date_select, which DOES take options.
- So, you need to override the column with a form column partial (look
at the AS docs for how to do this)
- call the method in your partial:

<%= active_scaffold_input_calendar_date_select(column, { :year_range
=> 3.years.ago..
> 0.years.ago }) %>

Cheers,
Dave

Ed W

unread,
Jul 24, 2008, 3:20:52 AM7/24/08
to actives...@googlegroups.com
Lightning Dave Bolton wrote:
On Jul 22, 9:26 pm, "mow...@googlemail.com" <mow...@googlemail.com>
wrote:
  
i assume that the options have to be given to the calendar while
creating it and can't be changed afterwards through
config.columns[:date].options. I'm not sure though, how it's possible
to give additional options to the config.columns[:date].form_ui
= :calendar_date_select statement.
    
Okay, I did this just yesterday, so you're in luck.

- AS doesn't pass through the column options you set, as you've
already identified.
  

I don't have the old bridge code to hand, but it does look like an interesting enhancement to perhaps add additional options via the active_scaffold_input_options function?  I guess the original bridge simply merged everything else in column.options into this hash?

Ed W

mow...@googlemail.com

unread,
Jul 24, 2008, 7:43:25 AM7/24/08
to ActiveScaffold : Ruby on Rails plugin
thanks dave, that works perfectly fine!
Reply all
Reply to author
Forward
0 new messages