Created
September 17, 2013 07:32
-
-
Save oziks/6591116 to your computer and use it in GitHub Desktop.
Validate Symfony Form Type with Entity method
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
<?php | |
.... | |
/** | |
* Validate Method | |
* | |
* @param ExecutionContext $context Execution context | |
* | |
* @return void | |
*/ | |
public function validateMethod(ExecutionContext $context) | |
{ | |
$context->addViolationAt('fields', 'Error Message.'); | |
} | |
.... |
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
<?php | |
.... | |
/** | |
* {@inheritdoc} | |
*/ | |
public function setDefaultOptions(OptionsResolverInterface $resolver) | |
{ | |
$resolver->setDefaults(array( | |
.... | |
'constraints' => array( | |
new Assert\Callback(array('methods' => array('validateMethod'))), | |
), | |
)); | |
} | |
.... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment