[html-formfu] model DBIC, belongs_to relationship, select, no update happens

Carl Franks fireartist at gmail.com
Wed Jan 7 16:21:04 GMT 2009


2008/12/25 Matija Grabnar <matija at serverflow.com>:
>
> So I have a table which has an integer field pointing at another table, like this:
>
> __PACKAGE__->table("subscription");
> __PACKAGE__->add_columns(
>  "id",
>  "schedule_type",
>  { data_type => "INT", default_value => undef, is_nullable => 0, size => 11 },
> (...)
> });
>
> __PACKAGE__->belongs_to(
>  "schedule_type",
>  "Schema::Model::DB::ScheduleType",
>  { id => "schedule_type" },
> );
>
> And the other table (schedule type)
>
> __PACKAGE__->add_columns(
>  "id",
>  { data_type => "INT", default_value => undef, is_nullable => 0, size => 11 },
>  "name",
>  {
>    data_type => "VARCHAR",
>    default_value => undef,
>    is_nullable => 0,
>    size => 255,
>  },
> );
> __PACKAGE__->set_primary_key("id");
> __PACKAGE__->has_many(
>  "subscriptions",
>  "Schema::Model::DB::Subscription",
>  { "foreign.schedule_type" => "self.id" },
> );
>
> What I want to happen is that when I'm editing the first table in formu,
> I should be able to display a select with ALL the fields from the
> schedule_type table, changing the schedule_type field if I
> change the select.
>
> Here is what I tried:
>
> elements:
>   - type: Block
>     elements:
>        - type: Select
>          name: scheduleType
>          label: page should be checked
>          model_config:
>            result_set: schedule_type
>            default_column: name
>
> If the name of the select is anything BUT scheduleType,
> I get an error when I want to form to render.
> Well, whatever, I can live with that, I guess.
>
> With this setup the form renders, but when I change the
> value of the select, and submit the form, the new value doesn't
> get saved. (I'm looking at the DBIC_TRACE, and there is no update).
>
>  If I change other fields in the form in addition to
> schedule_type, those other fields get updated, but schedule_type does not.
>
> Any idea what's going on?

The model_config attribute should be "resultset" - not "result_set".

The error is because it's not finding "resultset", so it's trying to
use ucfirst( $field->name )

Carl



More information about the HTML-FormFu mailing list