I've found a problem with the CRUD and hasOne() where the $display_field is ignored in the "add" form. If the referenced model has a 'name' field, then the drop down menu in the Add form of the CRUD is populated correctly. However, if the hasOne() model uses the $display_field parameter I'd expect the Add form to display the field specified, however it does not. It will only display the 'name' field or the 'id' of the referenced model rather than the field specified by $display. However, after the entry is added, the correct $display_field is used to display the entries. So the problem is somewhere in the Add operation.
For example:
Author
class Model_Author extends Model_Table {
public $table='author';
function init(){
parent::init();
$this->addField('long_name');
$this->addField('DOB');
}
}
Book
class Model_Book extends Model_Table {
public $table='book';
function init(){
parent::init();
$this->addField('title');
$this->hasOne('Author', 'author_id', 'long_name');
}
}
CRUD page.
class page_manager extends Page {
function init() {
parent::init();
$tabs=$this->add('Tabs');
$crud=$tabs->addTab('Book')->add('CRUD');
}
}
When you select the Add button, the Author field will display the id number of the authors in the author table. However, after you add a Book entry, the correct fields (i.e. long_name) is used to display the existing entries.
Cheers