bmidget/kohana-formo — Issue #173: overriding model attribute problem
Author: ierpe
Created: 2012-02-28 10:16:16+00:00
State: open

Hey,

I have a "belongs to" relationship in a model, like this:

protected $_belongs_to = array(
'release' => array(
'model' => 'release',
'foreign_key' => 'release_id',
),
);

By default, Formo displays a select with the release "id" as the option values and the release "name" as the option names.
In this case, I want to display more info in the option names, so I rebuild an array listing the releases.
So far so good.

The only thing is, I would expect this:
$form->add_group('release', 'select', $download->get_releases_select(), 0, array('label' => 'Release'));

to automatically override the select. but it does not, instead I need to do:
$form->add_group('releases', 'select', $download->get_releases_select(), 0, array('label' => 'Release'));
(I added a "s" to the select name) to get it to work.

Is this a wanted behavior? I thought I read in the doc that if you redeclare an existing attribute of the model it will be automatically overridden, but it doesn't seem to be the case.