Symfony1 如何在save()函数中访问no_监视器?

Symfony1 如何在save()函数中访问no_监视器?,symfony1,symfony-1.4,Symfony1,Symfony 1.4,我的表单中有一个configure()函数: public function configure() { $this->current_user = sfContext::getInstance()->getUser()->getGuardUser(); unset($this['updated_at'], $this['created_at']); $this->widgetSchema['idempresa'] = new sfWidget

我的表单中有一个
configure()
函数:

public function configure() {
    $this->current_user = sfContext::getInstance()->getUser()->getGuardUser();

    unset($this['updated_at'], $this['created_at']);

    $this->widgetSchema['idempresa'] = new sfWidgetFormInputHidden();
    $id_empresa = $this->current_user->getSfGuardUserProfile()->getIdempresa();
    $this->setDefault('idempresa', $id_empresa);

    $this->widgetSchema['no_emisor'] = new sfWidgetFormDoctrineChoice(array('model' => 'SdrivingEmisor', 'add_empty' => 'Seleccione un Emisor', 'expanded' => false, 'multiple' => false));
    $this->validatorSchema['idempresa'] = new sfValidatorPass();
    $this->validatorSchema['no_emisor'] = new sfValidatorPass();
}
我需要在
save()
函数中定义一个关系数据,所以我这样做:

public function save($con = null) {
    $new_machine = parent::save($con);

    $relation = new SdrivingMaquinaEmisor();
    $relation->setIdmaquina($new_machine);
    $relation->setIdemisor();
    $relation->save();

    return $new_machine;
}
为了设置
emissor
,当用户提交表单时,我如何访问所选值?这是实现这一目标的最佳方式吗

编辑 在听取关于如何访问
no\u emissor
值的建议后,现在我的代码如下所示:

public function save($con = null) {
    $new_machine = parent::save($con);

    $relation = new SdrivingMaquinaEmisor();
    $relation->setIdmaquina($new_machine);
    $relation->setIdemisor($this->values['no_emisor']);
    $relation->save();

    return $new_machine;
} 
但我得到了这个错误:

SQLSTATE[23000]:完整性约束冲突:1048列“idmaquina”不能为null


由于某些原因,
$new\u机器
不会返回最新保存元素的
id
。也许我做得不对,那么我做错了什么呢?

我想你可能想在表单的
doUpdateObject
中做这件事,因为它会接收清理后的值

编辑:


或者,
$this->values['no\u emissor']
在表单绑定后应该可以使用。

也许这个方法在其他时候对我有效,我只是不知道如何获取
no\u emissor