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

Steve Caldwell info-formfu at caldwellhb.com
Thu Feb 21 22:54:55 GMT 2008


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.

Anyone else come across this problem?  The work-around isn't that much
work (manually populate from and save to my object instead of using
defaults_from_model() and save_to_model()), but it would be cooler if it
all worked correctly.

-Steve




More information about the HTML-FormFu mailing list