开发者

getRelatedModelName - how show other column?

开发者 https://www.devze.com 2023-04-02 09:16 出处:网络
In abstract class BaseNewsForm extends BaseFormDoctrine i have widget: \'user_id\'=> new sfWidgetFormDoctrineChoice(array(\'model\' => $this->getRelatedModelName(\'User\'), \'add_empty\' =

In abstract class BaseNewsForm extends BaseFormDoctrine

i have widget:

  'user_id'     => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('User'), 'add_empty' => true)),

When i have add new News then i have list choice with ID all Users. How c开发者_开发知识库an i make change this list for Lastname? In table Users i have

id | username | name | lastname

i know that i must in NewsForm add:

$this->setWidget('user_id', new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('User'), 'add_empty' => true));

but how can i this edit for get Lastname, not ID?


$this->setWidget('user_id', new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('User'), 'add_empty' => true, 'method' => 'getLastname'));

0

精彩评论

暂无评论...
验证码 换一张
取 消