[html-formfu] Re: DBIC::Validation::FormFu RFC & Element::Date patch

Carl Franks fireartist at gmail.com
Fri Oct 19 19:23:19 GMT 2007


On 19/10/2007, Jonas Alves <jonas.alves at gmail.com> wrote:
> On 18/10/2007, Jonas Alves <jonas.alves at gmail.com> wrote:
> >
> > The only problem I had was with Element::Date. By default E::D params are
> returned like this:
> > {
> >     'date.day' => 1,
> >     'date.month' => 1,
> >     ' date.year' => 2007,
> > }
> > But it looks like that DBIC deletes all parameters with a dot in the name
> so I used C::Plugin::Params::Nested
> > to turn the params into this:
> > {
> >     date => {
> >         day => 1,
> >         month => 2,
> >         year => 2007,
> >     }
> > }
> > I wrote a patch to Element::Date to accept this struct as input too. This
> patch goes attached.
> >
>
> Hi Carl,
> I need this patch in Element::Date, is it not good?

Hi Jonas,

At first I had been holding off, in case we heard anything from mario
about his work on nested-params, as it would be preferable to solve
this throughout the form, rather than just a single element.
Regardless, I've just had a look at the patch, and I'm wondering if
you overlooked something, as it doesn't seem to be necessary.
For an example, if I run the following:

    $form = HTML::FormFu->new;
    $form->element({ type => 'Date', name => 'date' });

    $form->process({
        'date.day' => 1,
        'date.month' => 10,
        'date.year' => 2007,
    });

    print Dumper( $form->params );

I get the following output:

    $VAR1 = {
              'date.day' => 1,
              'date.month' => 10,
              'date.year' => '2007',
              'date' => '01-10-2007'
            };

So even if the names with a dot in them are deleted by DBIC, you've
still got the 'date' key.
I'm guessing you had either set strftime or used an Inflator to get the output:
    { date => '2007-01-01 00:00:00' }

Did you miss this, or am I not getting something?

Carl



More information about the HTML-FormFu mailing list