Skip to content

Instantly share code, notes, and snippets.

@bakura10
Created June 13, 2013 12:02
Show Gist options
  • Save bakura10/5773154 to your computer and use it in GitHub Desktop.
Save bakura10/5773154 to your computer and use it in GitHub Desktop.
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')
)
));
}
}
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