Created
June 13, 2013 12:02
-
-
Save bakura10/5773154 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
hpclass AdminEditForm extends Form | |
{ | |
/** | |
* {@inheritDoc} | |
*/ | |
public function init() | |
{ | |
$this->add(array( | |
'type' => 'User\Form\UserFieldset', | |
'name' => 'user', | |
'options' => array( | |
'use_as_base_fieldset' => true | |
) | |
)); | |
$this->add(array( | |
'type' => 'Csrf', | |
'name' => 'csrf' | |
)); | |
$this->add(array( | |
'type' => 'Submit', | |
'name' => 'submit', | |
'attributes' => array( | |
'value' => 'Modifier l\'utilisateur', | |
'class' => 'btn btn-primary' | |
) | |
)); | |
$this->setValidationGroup(array( | |
'user' => array( | |
'email', 'firstName', 'lastName', 'birthDate', 'phoneNumber', 'address', 'status', | |
'credit', 'paypalEmail', 'role', 'meta' => array('uplineCode', 'uplinedBy') | |
) | |
)); | |
} | |
} |
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 RegistrationForm extends Form implements ObjectManagerAwareInterface | |
{ | |
use ProvidesObjectManager; | |
/** | |
* {@inheritDoc} | |
*/ | |
public function init() | |
{ | |
$this->add(array( | |
'type' => 'User\Form\UserFieldset', | |
'name' => 'user', | |
'options' => array( | |
'use_as_base_fieldset' => true | |
) | |
)); | |
$this->add(array( | |
'type' => 'Csrf', | |
'name' => 'csrf' | |
)); | |
$this->add(array( | |
'type' => 'Submit', | |
'name' => 'submit', | |
'attributes' => array( | |
'value' => 'Je m\'inscris !' | |
) | |
)); | |
$this->setValidationGroup(array( | |
'user' => array( | |
'email', 'password', 'firstName', 'lastName', 'birthDate', 'phoneNumber', 'address' | |
) | |
)); | |
// Add the unique validator so that emails are unique | |
$userInput = $this->getInputFilter()->get('user')->get('email'); | |
$validators = $userInput->getValidatorChain(); | |
$validators->attach(new NoObjectExists(array( | |
'object_repository' => $this->objectManager->getRepository('User\Entity\User'), | |
'fields' => 'email' | |
))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment