function init(){
parent::init();
$f = $this->add('Form');
$f->addField('dropdown', 'Label:')->setModel('User');
}
So this code will output a dropdown list populated by the values in the table asosiated with the model User, but the values will be does of the name field in the model.
Is there a way to use another field of the model to populate this?
No direct way. First, are you sure you don't have to use 'reference' type instead of dropdown?
Secondly, free is how:
class Model_User_BySurname extends Model_User {
public function getListFields(){
return array('id'=>'id','surname'=>'name');
}
}
then further:
$form->addField('reference','Label')->setModel('User_BySurname');
Of course you can make this field re-defineable in your models, by creating some sort of "setNameField('surname')" function and hidden property used in getListFields.