【发布时间】:2011-07-08 09:54:14
【问题描述】:
我使用 symfony 1.4.11。我有前端和后端表单。
前端:
<?php
{
public function configure()
{
$user = sfContext::getInstance()->getUser()->getGuardUser()->getProfile();
$this->removeFields();
$this->widgField();
$this->widgetSchema->setLabels(array(
'time_id' => 'Duration *',
));
}
protected function removeFields()
{
unset(
$this['created_at'],
$this['updated_at'],
$this['is_closed'],
$this['invoice_url'],
$this['is_cancel']
);
}
protected function widgField()
{
$this->widgetSchema['user_id'] = new sfWidgetFormInputHidden();
}
protected function doUpdateObject($values)
{
parent::doUpdateObject($values);
$this->getObject()->setUserId(sfContext::getInstance()->getUser()->getGuardUser()->getId());
}
}
和后端:
<?php
class BackendPaymentForm extends PaymentForm
{
public function configure()
{
parent::configure();
}
protected function removeFields()
{
unset(
$this['updated_at'],
$this['created_at'],
$this['user_id'],
$this['time_id'],
$this['invoice_url'],
$this['is_cancel']
);
}
protected function widgField()
{
}
}
?>
问题是,我在前端 doUpdateObject 中设置了 user_id ,而在后端我需要管理员可以设置一个参数,一切都可以,但是它将 user_id 更改为管理员 id ...谢谢!
【问题讨论】:
-
更新:我修复了它,但我只在 8 小时后发布答案:(
标签: symfony1 symfony-1.4 symfony-forms