action:
public function executeTest($request)
{
if ($id = $this->getRequestParameter('id'))
{
$object = Doctrine::getTable('UllUser')->find($id);
}
else
{
$object = new UllUser;
}
$this->form = new testForm($object);
if ($request->isMethod('post') &&
$this->form->bindAndSave($request->getParameter('test')))
{
die('good!');
}
}
template:
<h1>testform</h1>
<form method='post'>
<?php echo $form ?>
<input type='submit' value='go'/>
</form>
testForm:
class testForm extends sfFormDoctrine
{
public function configure()
{
$this->setWidgets(array(
'first_name' => new sfWidgetFormInput(),
'name' => new sfWidgetFormInput(),
));
$this->setValidators(array(
'first_name' => new sfValidatorString(array('required' => true)),
'name' => new sfValidatorString(array('required' => true)),
));
$this->widgetSchema->setFormFormatterName('list');
$this->widgetSchema->setNameFormat('test[%s]');
}
public function getModelName()
{
return 'UllUser';
}
}