我有一个embeddedForm,我正在尝试配置窗口小部件。symfony - embedForm和窗体小部件不保存
目前我只是输出的形式在_form.php
模板,如:
<?php echo $form ?>
这是伟大的,但我想有我表单字段以特定的顺序,所以我想我会尝试:
<?php echo $form['firstname']->renderRow() ?>
<?php echo $form['lastname']->renderRow() ?>
<?php echo $form['email_address']->renderRow() ?>
这给了我一个无效的小部件错误。
现在我有2种形式,一种是基本形式,它简单地嵌入另一种形式。
<?php
class labSupportForm extends sfGuardUserAdminForm
{
public function configure()
{
$form = new labSupportProfileForm($this->getObject()->getProfile());
$this->embedForm('profile', $form);
unset($this['is_super_admin'], $this['is_admin'], $this['permissions_list'], $this['groups_list']);
$this->widgetSchema['profile'] = $form->getWidgetSchema();
$this->validatorSchema['profile'] = $form->getValidatorSchema();
}
public function save($con = null)
{
$user = parent::save($con);
if (!$user->hasGroup('Lab Support'))
{
$user->addGroupByName('Lab Support');
$user->save();
}
return $user;
}
}
和:
<?php
class labSupportProfileForm extends sfGuardUserProfileForm
{
public function configure()
{
unset($this['email_new'],
$this['validate_at'],
$this['validate'],
$this['address_1'],
$this['address_2'],
$this['city'],
$this['country'],
$this['postcode'],
$this['created_at'],
$this['updated_at'],
$this['user_id'],
$this['is_super_admin'],
$this['is_admin'],
$this['permissions_list'],
$this['groups_list']);
}
}
,但如果我的窗口小部件/验证添加到labSupportForm
和保存时,firstname
值不保存。
我在这里做错了什么,因为我会认为这个值会节省。
感谢
你不必写$这个 - > widgetSchema [“个人资料”] = $形式 - > getWidgetSchema(),这是自动由embedForm方法处理,sa我为验证模式。 – Dziamid 2011-04-26 16:30:06