Created
August 22, 2012 16:27
-
-
Save gzankevich/3427209 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(), | |
)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
array (size=2) | |
0 => string 'The fields "introduction" are missing' (length=43) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ form_row(form) }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment