Hi,
i am a newbie to symfony. am follwoing an example from the 'symfony forms in action' where a form is created the some validation methods are introduced. my problem is that when i enter invalid data into the forms and click submit, the form clears all the fields and brings up the error message *required. what might be the problem. here is my code:
apps/frontend/modules/contact/templates/indexSucces.php
<form action="<?php echo url_for('contact/index') ?>" method="POST">
<table>
<?php echo $form ?>
<tr>
<td colspan="2">
<input type="submit" />
</td>
</tr>
</table>
</form>
lib/form/ContactForm.class.php
class ContactForm extends BaseForm
{
protected static $subjects = array('Subject A', 'Subject B', 'Subject C');
public function configure()
{
$this->setWidgets(array(
'name' => new sfWidgetFormInputText(),
'email' => new sfWidgetFormInputText(),
'subject' => new sfWidgetFormSelect(array('choices' => self::$subjects)),
'message' => new sfWidgetFormTextarea(),
));
$this->widgetSchema->setNameFormat('contact[%s]');
$this->setValidators(array(
'name' => new sfValidatorString(array('required' => false)),
'email' => new sfValidatorEmail(),
'subject' => new sfValidatorChoice(array('choices' => array_keys(self::$subjects))),
'message' => new sfValidatorString(array('min_length' => 4)),
));
}
}
/frontend/modules/contact/action/action.class.php
class contactActions extends sfActions
{
public function executeIndex($request)
{
$this->form = new ContactForm();
if ($request->isMethod('post'))
{
$this->form->bind($request->getParameter('contact'));
if ($this->form->isValid())
{
$this->redirect('contact/thankyou?'.http_build_query($this->form->getValues()));
}
}
}
public function executeThankyou()
{
}
}