On Jan 16, 2006, at 2:57 PM, Steve Ross wrote:
> I have a decoupled form embedded in my pages ? a search box that
> has date fields ? and of course the search fields are not in my
> model. However, picking dates is a great use for the Dynarch
> calendar. It seems that by using the syntax:
>
> <%= render :partial => ?filter_box? %>
>
> In my view and...
>
> <%= dynarch_date_select ''filter_box'',
''begin_date'' %>
>
> I receive the following in my params hash:
>
> "begin_date"=>{"date"=>"01/01/2006"}}
>
> I constructed a faux model FilterBox just for the occasion, but as
> you might expect, it can?t be created as easily as you might think
> because of the trailing ?date? in the field id.
>
> Here?s the generated HTML:
>
> <input id="filter_box_begin_date_date"
name="filter_box[begin_date]
> [date]" type="text" value="" />
>
> Is there a way I?m not seeing to get the id to be
> ?filter_box_begin_date? and the name to be ?filter_box
> [begin_date]?? I think it would be far more natural to use...
>
> Thoughts?
>
Hi Steve,
Yeah, that''s my hack you''ve pointed out there ;)
The reason for its weirdness is that I wanted dynarch to replace the
built-in Rails date_select. But the input for date and time
selection in Rails is kind of strange to begin with--it''s broken up
in to 5 parts like this:
filter_box[begin_date(1i)] # year
filter_box[begin_date(2i)] # month
filter_box[begin_date(3i)] # day
filter_box[begin_date(4i)] # hour
filter_box[begin_date(5i)] # min
In the implementation of the dynarch calendar, you need to add a
"convert_date_to_multi_params!(params[:filter_box], :begin_date)" as
soon as you can so that the extra "date" hash inside there will be
converted to the expected 1i, 2i, 3i etc. format above.
Originally, I had hoped to make this somehow automatic, but I
couldn''t find a way. The existence of the extra "date" hash
is a
relic of my attempt at automating the conversion process. Does
adding the convert_date_to_multi_params! method solve the problem
you''re up against?
Duane Johnson
(canadaduane)
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060119/3fd7b1c1/attachment.html