With the Catalyst controller the schema is set from the model_name config options, ($c->model($model_name)...), but it can also be set by passing in the schema on "new", or setting with $form->schema($schema). You can also set a config values for whether or not to use FillInForm, and the form namespace.

This DBIC model will save form fields automatically to the database, will retrieve selection lists from the database (with type => 'Select' and a fieldname containing a single relationship, or type => 'Multiple' and a many_to_many pseudo-relationship), and will save the selected values (one value for 'Select', multiple values in a mapping table for a 'Multiple' field).

This package includes a working example using a SQLite database and a number of forms. The templates are straightforward and unoptimized to make it easier to see what they're doing.

This is not the same as the routine called with $self->update_from_form. That is a Catalyst plugin routine that calls this one. This routine updates or creates the object from values in the form.

All fields that refer to columns and have changed will be updated. Field names that are a single relationship will be updated. Any field names that are related to the class by "many_to_many" are assumed to have a mapping table and will be updated. Validation is run unless validation has already been run. ($form->clear might need to be called if the $form object stays in memory between requests.)

The actual update is done in the update_model method. Your form class can override that method (but don't forget to call SUPER) if you wish to do additional database inserts or updates. This is useful when a single form updates multiple tables, or there are secondary tables to update.

Returns false if form does not validate, otherwise returns 1. Very likely dies on database errors.

This is where the database row is updated. If you want to do some extra database processing (such as updating a related table) this is the method to subclass in your form.

This routine allows the use of non-database (non-column, non-relationship) accessors in your result source class. It identifies form fields as 1) column, 2) relationship, 3) other. Column and other fields are processed and update is called on the row. Then relationships are processed.

If the row doesn't exist (no primary key or row object was passed in), then a row is created using "create" and the fields identified as columns passed in a hashref, followed by "other" fields and relationships.

This method is used with "Single" and "Multiple" field select lists ("single", "filter", and "multi" relationships). It returns an array reference of key/value pairs for the column passed in. The column name defined in $field->label_column will be used as the label. The default label_column is "name". The labels are sorted by Perl's cmp sort.

If there is an "active" column then only active values are included, except if the form (item) has currently selected the inactive item. This allows existing records that reference inactive items to still have those as valid select options. The inactive labels are formatted with brackets to indicate in the select list that they are inactive.

This is called first time $form->item is called. If using the Catalyst plugin, it sets the DBIx::Class schema from the Catalyst context, and the model specified as the first part of the object_class in the form. If not using Catalyst, it uses the "schema" passed in on "new".

It then does:

return $self->resultset->find( $self->item_id );

It also validates that the item id matches /^\d+$/. Override this method in your form class (or form base class) if your ids do not match that pattern.

If a database row for the item_id is not found, item_id will be set to undef.