[html-formfu] DBIC: setting accessor for a Select element triggers options_from_model()

Carl Franks fireartist at gmail.com
Fri Feb 22 14:21:30 GMT 2008


On 22/02/2008, Zbigniew Lukasiak <zzbbyy at gmail.com> wrote:
> On Thu, Feb 21, 2008 at 11:54 PM, Steve Caldwell
>
> <info-formfu at caldwellhb.com> wrote:
>
> > I'm building a form that has a Select element that I'm mapping to a
>  >  non-column accessor on my DBIC object, as described in "non-column
>  >  accessors" in the HTML::FormFu::Model::DBIC POD, like this:
>  >
>  >  ---
>  >  action: /foo
>  >  elements:
>  >   - type: Select
>  >     name: bar
>  >     label: Your Bar
>  >     db:
>  >       accessor: bar
>  >     options:
>  >       - [ 01, January ]
>  >       - [ 02, February ]
>  >
>  >  When I then try and populate it from my DBIC object:
>  >
>  >  $form->defaults_from_model( $myobj );
>  >
>  >  HTML::FormFu::Model::DBIC::options_from_model gets called (thanks to
>  >  line 44 in HTML::FormFu::Element::_Group), which then overwrites the
>  >  options I've set from my select list with a bunch of stuff from the
>  >  database.  This is obviously not what I want here.
>
>
> Just for clarification in that 44 line in
>  HTML::FormFu::Element::_Group you are in post_process - and
>  post_process is called after processing the form not in the
>  options_from_model call.
>
>  Can anyone confirm that?

Yes, options_from_model() should only be getting called during $form->process()
not during defaults_from_model()

Carl



More information about the HTML-FormFu mailing list