Created
May 10, 2012 22:14
-
-
Save leftdevel/2656240 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
<?php | |
/** | |
* Este es el action donde se envió el formulario. | |
*/ | |
public function paso2Action() | |
{ | |
$object = new Object(); | |
$request = $this->getRequest(); | |
$form = $this->createForm(new ObjectType(), $object); | |
$form->bindRequest($request); | |
// Si la cuenta es nueva o existente, establecer el validation_group necesario | |
$validation_group = true === $object->getUseExisting() | |
? 'no_validar_username_password' | |
: 'si_validar_username_password'; | |
// Volver a crear el formulario de modo que se utilice el validation_group adecuado | |
$form = $this->createForm(new ObjectType(), $object, array( | |
'validation_groups' => array($validation_group), | |
)); | |
$form->bindRequest($request); // Vuelve la mula al trigo :D | |
if (true === $form->isValid()) { // Esto debe validar acorde al grupo que se le pasó como argumento | |
// Hacer lo que sea necesario... | |
// Persistir. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment