public function buildForm(FormBuilderInterface $builder, array $options) { // add your custom field $builder->add('fullname', null, array('label' => 'form.fullname')); parent::buildForm($builder, $options); $builder->remove('username'); /* $builder->add('timezone', 'city_entity',array( 'class' => 'AcmeEdelaBundle:City', 'property' => 'title', 'label' => 'form.timezone' ) Acme\EdelaBundle\Entity\City );*/ $builder->add('timezone', 'shtumi_ajax_autocomplete', array('entity_alias' => 'cities')); // Add hook on submitted data in order to copy email into username $um = $this->userManager; $builder->addEventListener(FormEvents::SUBMIT, function (FormEvent $event) use($um) { $user = $event->getData(); /** @var User $user */ if ($user) { // Set username like email and canonicalize both fields $user->setUsername($user->getEmail()); $um->updateCanonicalFields($user); } }); }
public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); // custom fields $builder->add('super', 'checkbox', array('label' => 'Looking for Super Admin account:', 'required' => false)); $builder->add('dbNameUq', 'text', array('label' => 'Database name (only lower case letters):', 'required' => false)); $builder->add('defaultlanguage', 'language', array('label' => 'Default language:', 'required' => false)); // custom validation $extraValidator = function (FormEvent $event) { $form = $event->getForm(); $dbNameUq = $form->get('dbNameUq'); $defaultlanguage = $form->get('defaultlanguage'); $super = $form->get('super')->getData(); if (!$super) { if (!is_null($dbNameUq->getData())) { if (!ctype_lower($dbNameUq->getData())) { $dbNameUq->addError(new FormError("This field is not valid (only lower case letters)")); } if (strlen($dbNameUq->getData()) < 3 || strlen($dbNameUq->getData()) > 50) { $dbNameUq->addError(new FormError("This field must contain 3 to 50 lower case letters")); } } else { $dbNameUq->addError(new FormError("This field must not be empty")); } if (is_null($defaultlanguage->getData())) { $defaultlanguage->addError(new FormError("This field must not be empty")); } } }; $builder->addEventListener(FormEvents::POST_BIND, $extraValidator); }
public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); // add your custom field //$builder->add('password', 'password'); //$builder->add('username', null, array('label' => 'form.username', 'translation_domain' => 'FOSUserBundle', 'attr' => array('class'=>'myClass'))); }
public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); $builder->remove('username'); $builder->remove('plainPassword'); $builder->add('profile', new SlaveClientProfileFormType()); $factory = $builder->getFormFactory(); $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use($factory) { $form = $event->getForm(); $user = $event->getData(); $access = 'limited'; if ($user && $user->hasRole('ROLE_CLIENT_FULL')) { $access = 'full'; } $form->add($factory->createNamed('access', 'choice', $access, array('choices' => array('full' => 'Full', 'limited' => 'Limited'), 'mapped' => false))); }); $builder->addEventListener(FormEvents::BIND, function (FormEvent $event) { $form = $event->getForm(); $user = $event->getData(); $access = $form->get('access')->getData(); if ($user->hasRole('ROLE_CLIENT_FULL') && $access === 'limited') { $user->removeRole('ROLE_CLIENT_FULL'); } if (!$user->hasRole('ROLE_CLIENT_FULL') && $access === 'full') { $user->addRole('ROLE_CLIENT_FULL'); } /** @var User $user */ $user->setUsername($user->getEmail()); }); }
public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); // add your custom field $builder->add('tenantName', 'text', array('mapped' => false)); $builder->add('tenantSubdomain', 'text', array('label' => 'subdomain', 'mapped' => false)); }
public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); // add your custom field $builder->add('prenom'); $builder->add('adresse'); }
public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); // add your custom field $builder->add('firstName'); $builder->add('lastName'); $builder->add('wage'); }
public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); $builder->add('nombre'); $builder->add('apellido'); $builder->add('dni'); //$builder->add('presupuestos'); 'entity', array( 'class' => 'FantasiaBundle:Presupuesto )); }
public function buildForm(Form\FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); $builder->add('plan', 'entity', ['class' => $this->plan_class, 'expanded' => true, 'mapped' => false])->add('referrer', 'simpleweb_saas_referrer'); $builder->addEventListener(Form\FormEvents::POST_SET_DATA, function (Form\FormEvent $event) { $event->getForm()->get('referrer')->setData($this->session->get('referrer')); }); }
/** * @param FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('firstName', 'text', array('label' => 'open_orchestra_user_admin.form.registration_user.first_name'))->add('lastName', 'text', array('label' => 'open_orchestra_user_admin.form.registration_user.last_name')); parent::buildForm($builder, $options); if (array_key_exists('disabled', $options)) { $builder->setAttribute('disabled', $options['disabled']); } }
public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('firstName', 'text', array('label' => 'sylius.form.user.first_name')); $builder->add('lastName', 'text', array('label' => 'sylius.form.user.last_name')); parent::buildForm($builder, $options); // remove the username field $builder->remove('username'); }
public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); // add your custom field $builder->add('name'); //$builder->add('invitation', 'project_invitation_type'); $builder->add('file'); $builder->add('descripcion'); }
public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); // add your custom field $builder->add('fullname', null, array('label' => "Full Name: ")); $builder->get('username')->setAttribute('label', 'Username'); $builder->get('plainPassword')->get('first')->setAttribute('label', 'Password'); $builder->get('plainPassword')->get('second')->setAttribute('label', 'Confirm Password'); }
public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); // add your custom field $builder->add('sex', 'choice', array('label' => 'Пол', 'multiple' => false, 'choices' => array(1 => 'мужской', 2 => 'женский'), 'data' => 1))->add('race', 'entity', array('class' => 'Rottenwood\\UtopiaMudBundle\\Entity\\Race', 'query_builder' => function (EntityRepository $repository) { return $repository->createQueryBuilder('r')->select('r'); // ->where('r.id > 0'); })); }
public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); // add your custom field $builder->add('name'); $builder->add('dob'); $builder->add('gender'); $builder->add('location'); }
public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('profile', new RiaProfileType(), array('label' => ' ')); parent::buildForm($builder, $options); $builder->remove('username'); $builder->addEventListener(FormEvents::BIND, function (FormEvent $event) { $user = $event->getData(); $user->setUsername($user->getEmail()); }); }
public function buildForm(FormBuilder $builder, array $options) { parent::buildForm($builder, $options); // add your custom field $builder->add('empleado', 'entity', array('class' => 'ISRI\\SidPla\\AdminBundle\\Entity\\Empleado', 'query_builder' => function (EntityRepository $er) { return $er->createQueryBuilder('u')->orderBy('u.primerNombre', 'ASC'); })); $builder->add('rol', 'entity', array('class' => 'ISRI\\SidPla\\AdminBundle\\Entity\\RolSistema', 'query_builder' => function (EntityRepository $er) { return $er->createQueryBuilder('u')->orderBy('u.nombreRol', 'ASC'); })); }
public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); // add your custom field $builder->add('nom'); $builder->add('prenom'); $builder->add('adresse'); $builder->add('datedenaissance'); $builder->add('telephone'); $builder->add('descriptif'); $builder->add('societe'); }
public function buildForm(FormBuilder $builder, array $options) { parent::buildForm($builder, $options); // add your custom field $builder->add('name'); $builder->add('firstname'); $builder->add('country', 'country'); $builder->add('region'); $builder->add('city'); $builder->add('address'); $builder->add('tel'); }
public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); $data = $builder->getData(); $builder->remove('username', 'text')->remove('plainPassword')->add('profile', new CreateClientProfileType($this->ria, $data)); $plainPassword = $this->generatePlainPassword(); $builder->addEventListener(FormEvents::BIND, function (FormEvent $event) use($plainPassword) { $user = $event->getData(); $user->setUsername($user->getEmail()); $user->setPlainPassword($plainPassword); }); }
public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); // add your custom field $builder->add('type', 'choice', array('choices' => array('S' => 'Single user', 'G' => 'Groupe'), 'required' => true)); $builder->add('groupename'); $builder->add('title', 'choice', array('choices' => array('M' => 'Monsieur', 'F' => 'Madame'), 'required' => true)); $builder->add('firstname'); $builder->add('lastname'); $builder->add('birthDate'); $builder->add('postaladress'); $builder->add('phone'); $builder->add('profession'); }
public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); $builder->add('id', 'hidden'); $builder->add('userPrimerNombre', null, array('label' => 'Primer Nombre')); $builder->add('userSegundoNombre', null, array('label' => 'Segundo Nombre')); $builder->add('userApellidos', null, array('label' => 'Apellidos')); $builder->add('userDui', null, array('label' => 'DUI')); $builder->add('userNit', null, array('label' => 'NIT')); $builder->add('userCargo', null, array('label' => 'Cargo que desempeña')); $builder->add('userTelefono', 'text', array('label' => 'Teléfono', 'required' => true)); $builder->add('userInterno', 'hidden', array('label' => 'Usuario Interno?')); $builder->add('userInternoTipo', 'choice', array('label' => 'Ministerio al que pertenece', 'empty_value' => 'Seleccione un Ministerio', 'required' => false, 'expanded' => false, 'multiple' => false, 'choices' => array(User::$MINSAL => User::$MINSAL_TEXT, User::$DGII => User::$DGII_TEXT, User::$DGA => User::$DGA_TEXT, User::$MH => User::$MH_TEXT, User::$DNM => User::$DNM_TEXT))); $builder->add('userTipo', 'choice', array('label' => 'Acciones que Realizará', 'empty_value' => 'Seleccione una Acción', 'required' => true, 'expanded' => false, 'multiple' => false, 'choices' => array(User::$COMPRADOR_VENDEDOR => User::$COMPRADOR_VENDEDOR_TEXT, User::$VENDEDOR => User::$VENDEDOR_TEXT, User::$COMPRADOR => User::$COMPRADOR_TEXT, User::$DIGITADOR => User::$DIGITADOR_TEXT, User::$APROBADOR => User::$APROBADOR_TEXT))); }
public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); // $builder // ->add('email', 'email', array('label' => 'form.email', 'translation_domain' => 'FOSUserBundle')) // ->add('plainPassword', 'repeated', array( // 'type' => 'password', // 'options' => array('translation_domain' => 'FOSUserBundle'), // 'first_options' => array('label' => 'form.password'), // 'second_options' => array('label' => 'form.password_confirmation'), // 'invalid_message' => 'fos_user.password.mismatch', // )) // ; // // add your custom field // $builder->add('name'); }
public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); // add your custom field $builder->remove('username'); $builder->add('name', null, array('label' => 'Dojo Name')); $builder->add('location', null, array('label' => 'Location Name')); $builder->add('street'); $builder->add('housenumber'); $builder->add('postalcode'); $builder->add('city'); $builder->add('facebook', null, array('attr' => array('placeholder' => 'http://facebook.com/yourpage'))); $builder->add('twitter', null, array('attr' => array('placeholder' => 'http://twitter.com/yourtwitter'))); $builder->add('website', null, array('attr' => array('placeholder' => 'http://coderdojo-[CITY].nl'))); $builder->add('organiser', null, array('attr' => array('placeholder' => 'Eventbrite Organiser ID (see link below)'))); }
/** * @param FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface $builder, array $options) { $transformer = new NameToIdTransformer($this->entityManager); parent::buildForm($builder, $options); $builder->add($builder->create('city', 'text', array('required' => true, 'label' => 'Ville sélectionnée', 'attr' => array('data-id' => 'city', 'class' => 'form-control', 'readonly' => true, 'placeholder' => 'Ville choisie')))->addModelTransformer($transformer))->add('codePostal', 'text', array('mapped' => false, 'required' => true, 'label' => 'Code postal', 'constraints' => array(new NotBlank(array('message' => 'Le code postal ne doit pas être vide')), new Length(array('min' => 5, 'max' => 5)), new Regex(array('pattern' => "/^[0-9]+\$/", "message" => 'Le code postal ne peut contenir que des chiffres'))), 'attr' => array('data-id' => 'codePostal', 'class' => 'form-control only_alpha_num no_paste', 'placeholder' => 'Code Postal ( ex : 13100 )', 'maxlength' => 5))); $builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) { $data = $event->getData(); $postal = $data['codePostal']; $city = $data['city']; $form = $event->getForm(); $cityCheck = $this->entityManager->getRepository('SnoozitPlatformBundle:Localisation\\City')->findOneBy(array('nom' => $city, 'postal' => $postal)); if (!$cityCheck) { $form->addError(new FormError('Il y a une incohérence entre le code postal et la ville choisie')); } return; }); }
public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); // add your custom field // $builder->add('name'); $builder->remove('username'); // we use email as the username /* $builder->add('captcha', 'captcha', array( 'width' => 150, 'height' => 50, 'length' => 6, 'reload'=>'true', 'as_url'=>'true', 'distortion'=>false, 'max_front_lines'=>0, 'max_behind_lines'=>0, 'interpolation'=>false, 'gc_freq'=>0, )); */ }
public function buildForm(FormBuilderInterface $builder, array $options) { //questo prende tutte le voci del form FOS parent::buildForm($builder, $options); $builder->remove('username'); // we use email as the username //qui si possono aggiungere campi personalizzati // $builder // ->add('gender', 'choice', array( // 'label' => 'form.sesso', // 'translation_domain' => 'FOSUserBundle', // 'choices' => array('m' => 'form.maschio', 'f' => 'form.femmina'), // 'expanded' => true, // 'required' => true, // ) // ->add('citta', null, array('label' => 'form.citta', 'translation_domain' => 'FOSUserBundle')) // ->add('yearOfBirth', 'date', array('label' => 'form.compleanno', // 'translation_domain' => 'FOSUserBundle','widget' => 'choice', 'format' => 'dd-MM-yyyy','years' => range(1920, date('Y')-18)) // ); }
public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); $ria = $this->ria; $factory = $builder->getFormFactory(); $choices = array(self::TYPE_ADMIN => 'Admin', self::TYPE_USER => 'User'); $builder->remove('username', 'text')->remove('plainPassword')->add('profile', new CreateUserProfileFormType($ria))->add('groups', 'entity', array('multiple' => true, 'property' => 'name', 'label' => 'Groups:', 'class' => 'Wealthbot\\UserBundle\\Entity\\Group', 'query_builder' => function (EntityRepository $er) use($ria) { return $er->createQueryBuilder('g')->andWhere('g.owner = :owner')->orWhere('g.owner is null')->setParameter('owner', $ria); })); $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use($ria, $factory, $choices) { $form = $event->getForm(); $user = $event->getData(); $type = CreateUserFormType::TYPE_ADMIN; if ($user && !$user->hasRole('ROLE_RIA_ADMIN')) { $type = CreateUserFormType::TYPE_USER; } if (!($user && $user->hasRole('ROLE_RIA'))) { $form->add($factory->createNamed('type', 'choice', $type, array('choices' => $choices, 'mapped' => false, 'label' => 'Type:'))); } }); $builder->addEventListener(FormEvents::BIND, function (FormEvent $event) use($ria) { /** @var $user User */ $user = $event->getData(); $form = $event->getForm(); $user->setUsername($user->getEmail()); $user->setEnabled(true); if ($form->has('type')) { $type = $form->get('type')->getData(); if ($type == CreateUserFormType::TYPE_ADMIN) { $user->setRoles(array('ROLE_RIA_ADMIN')); } else { $user->setRoles(array('ROLE_RIA_USER')); } } }); }
/** * {@inheritdoc} */ public function configureOptions(OptionsResolver $resolver) { parent::configureOptions($resolver); $resolver->setDefault('csrf_protection', false); }
public function getDefaultOptions(array $options) { parent::getDefaultOptions($options); return array('data_class' => 'Inra2013\\urzBundle\\Entity\\User'); }