Forum: Ruby on Rails Bundled resource -- something I'm missing

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
38f53ebf43385729eda5ff0d18483bd7?d=identicon&s=25 Steve Ross (Guest)
on 2006-01-17 01:58
(Received via mailing list)
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?

Thanks
D8cb8c8cd40ddf0cd05241443a591868?d=identicon&s=25 Duane Johnson (Guest)
on 2006-01-19 15:02
(Received via mailing list)
On Jan 16, 2006, at 2:57 PM, Steve Ross wrote:

>
> <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)
This topic is locked and can not be replied to.