Skip to content

Instantly share code, notes, and snippets.

@gzankevich
Created August 22, 2012 16:27
Show Gist options
  • Save gzankevich/3427209 to your computer and use it in GitHub Desktop.
Save gzankevich/3427209 to your computer and use it in GitHub Desktop.
public function whateverAction()
{
$form = $this->createForm(new ViewingReportType($viewings));
$form->bindRequest($this->getRequest());
if($form->isValid()) {
die('valid');
}
var_dump($this->getFormErrors($form));
return $this->render('PhoenixCRMBundle:Something:index.html.twig', array(
'form' => $form->createView(),
));
}
class MyFormType extends AbstractType
{
public function buildForm(FormBuilder $builder, array $options)
{
$builder
->add('introduction', 'textarea', array(
'required' => true,
'property_path' => false,
))
;
}
public function getDefaultOptions(array $options)
{
// REMOVING THIS METHOD GETS RID OF THE ERROR
$collectionConstraint = new Collection(array(
'introduction' => new NotBlank()
));
return array('validation_constraint' => $collectionConstraint);
}
}
array (size=2)
0 => string 'The fields "introduction" are missing' (length=43)
{{ form_row(form) }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment