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

Matija Grabnar matija at serverflow.com
Thu Dec 25 16:33:08 GMT 2008


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?






More information about the HTML-FormFu mailing list