У меня есть встроенная форма, для которой я пытаюсь настроить виджеты.
В настоящее время я просто выводю форму в шаблоне _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
не сохраняется.
Я что-то здесь не так делаю, поскольку я думал, что это значение сохранит.
Спасибо