/** * {@inheritdoc} */ public function configureOptions(OptionsResolver $resolver) { parent::configureOptions($resolver); if ($this->formType) { $this->formType->configureOptions($resolver); } }
public function formEncode($entity, Form $form, AbstractType $formType) { $baseName = $formType->getName(); $payload = array(); foreach ($form->getIterator() as $el) { if (is_array($entity)) { $payload[$baseName . '[' . $el->getName() . ']'] = $entity[$el->getName()]; } } return $payload; }
/** * @param AbstractType $type * @param ConfigIdInterface $configId * @param bool $immutable * @param array $options * @param array $expectedOptions * * @return array */ protected function doTestSetDefaultOptions(AbstractType $type, ConfigIdInterface $configId, $immutable, array $options = [], array $expectedOptions = []) { $this->setIsReadOnlyExpectations($configId, $immutable); $resolver = $this->getOptionsResolver(); $type->setDefaultOptions($resolver); $options['config_id'] = $configId; $resolvedOptions = $resolver->resolve($options); foreach ($expectedOptions as $name => $val) { $this->assertEquals($val, $resolvedOptions[$name], $name); unset($resolvedOptions[$name]); } return $resolvedOptions; }
protected function getEntityErrorMap($entity, AbstractType $formType = null) { /** @var ConstraintViolation[] $errors */ $errors = $this->get('validator')->validate($entity); $mapping = []; foreach ($errors as $err) { if ($formType === null) { $mapping[$err->getPropertyPath()] = $err->getMessage(); } else { $mapping[$formType->getName() . '_' . $err->getPropertyPath()] = $err->getMessage(); } } return $mapping; }
/** * @param \Symfony\Component\OptionsResolver\OptionsResolverInterface $resolver * * @return void */ public function setDefaultOptions(OptionsResolverInterface $resolver) { parent::setDefaultOptions($resolver); $resolver->setRequired(self::OPTION_SALUTATION_CHOICES); $resolver->setRequired(self::OPTION_COUNTRY_CHOICES); $resolver->setRequired(self::OPTION_PREFERRED_COUNTRY_CHOICES); }
/** * (non-PHPdoc) * @see \Symfony\Component\Form\AbstractType::buildForm() */ public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); $builder->add('title', 'text'); //$builder->add('category'); $builder->add('post', $options['post_form'], array('data_class' => $options['post_class'], 'label' => false, 'mapped' => false)); }
/** * {@inheritdoc} */ public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); if (true === $options['multiple']) { $builder->addViewTransformer(new CollectionToArrayTransformer(), true); } }
public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); $builder->add('Notas', null, array('label' => 'Asunto', 'attr' => array('placeholder' => ''), 'required' => true))->add('Categoria', 'Symfony\\Bridge\\Doctrine\\Form\\Type\\EntityType', array('label' => 'Categoría', 'attr' => array('help' => 'Si no sabe cual seleccionar, puede dejarla en blanco para que el administrador asigne una.'), 'class' => 'Yacare\\RequerimientosBundle\\Entity\\Categoria', 'query_builder' => function (\Yacare\RequerimientosBundle\Entity\CategoriaRepository $er) { return $er->ObtenerQueryBuilderPublicas(); }, 'required' => false))->add('UsuarioNombre', null, array('label' => 'Nombre', 'attr' => array('placeholder' => 'Su nombre'), 'required' => false))->add('UsuarioEmail', 'Symfony\\Component\\Form\\Extension\\Core\\Type\\EmailType', array('label' => 'E-mail', 'attr' => array('placeholder' => 'Su dirección de correo electrónico'), 'required' => false))->add('UsuarioDireccion', null, array('label' => 'Dirección', 'attr' => array('placeholder' => 'Su domicilio'), 'required' => false))->add('UsuarioTelefono', null, array('label' => 'Teléfono', 'attr' => array('placeholder' => 'Su número de teléfono'), 'required' => false)); }
public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); $builder->add('Notas', null, array('label' => 'Notas', 'required' => false))->add('Usuario', 'Symfony\\Bridge\\Doctrine\\Form\\Type\\EntityType', array('label' => 'Encargado', 'choice_label' => 'NombreVisible', 'attr' => array('class' => 'tapir-input-320'), 'class' => 'Yacare\\BaseBundle\\Entity\\Persona', 'query_builder' => function (\Yacare\BaseBundle\Entity\PersonaRepository $er) { return $er->ObtenerQueryBuilderPorRol('ROLE_REQUERIMIENTOS_ENCARGADO'); }))->add('Requerimiento', 'Tapir\\FormBundle\\Form\\Type\\EntityHiddenType', array('class' => 'Yacare\\RequerimientosBundle\\Entity\\Requerimiento')); }
/** * {@inheritdoc} */ public function finishView(FormView $view, FormInterface $form, array $options) { parent::finishView($view, $form, $options); // convert the route into an URL $view->vars['limit'] = $options['limit']; $view->vars['url'] = $options['url']; }
public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); $builder->add('Notas', null, array('label' => 'Notas', 'required' => false))->add('Usuario', 'entity', array('label' => 'Encargado', 'property' => 'NombreVisible', 'class' => 'Yacare\\BaseBundle\\Entity\\Persona', 'query_builder' => function (\Yacare\BaseBundle\Entity\PersonaRepository $er) { return $er->ObtenerQueryBuilderPorRol('ROLE_REQUERIMIENTOS_ENCARGADO'); }))->add('Requerimiento', 'entity_hidden', array('class' => 'Yacare\\RequerimientosBundle\\Entity\\Requerimiento')); }
/** * @param FormView $view * @param FormInterface $form * @param array $options */ public function buildView(FormView $view, FormInterface $form, array $options) { parent::buildView($view, $form, $options); if (isset($view->vars['name']) && '' !== $view->vars['name'] && null !== $view->vars['name']) { $view->vars['label'] = 'open_orchestra_backoffice.form.content_type.default_listable_label.' . $view->vars['name']; } }
public function buildForm(FormBuilderInterface $builder, array $options) { // On fait appel à la méthode buildForm du parent, qui va ajouter tous les champs à $builder parent::buildForm($builder, $options); // On supprime celui qu'on ne veut pas dans le formulaire de modification $builder->remove('name'); }
/** * {@inheritdoc} */ public function configureOptions(OptionsResolver $resolver) { parent::configureOptions($resolver); $resolver->setDefaults(array('nameable' => false, 'deleteable' => false, 'downloadable' => true, 'maxWidth' => 320, 'maxHeight' => 180, 'minWidth' => 16, 'minHeight' => 16, 'previewImages' => true, 'previewAsCanvas' => true, 'previewFilter' => null, 'multipart' => true, 'novalidate' => true, 'required' => false)); $resolver->setAllowedValues('multipart', array(true))->setAllowedValues('novalidate', array(true))->setAllowedValues('required', array(false)); $resolver->setAllowedTypes('nameable', array('string', 'bool'))->setAllowedTypes('deleteable', array('string', 'bool'))->setAllowedTypes('downloadable', array('bool'))->setAllowedTypes('maxWidth', array('integer'))->setAllowedTypes('maxHeight', array('integer'))->setAllowedTypes('minWidth', array('integer'))->setAllowedTypes('minHeight', array('integer'))->setAllowedTypes('previewImages', array('bool'))->setAllowedTypes('previewAsCanvas', array('bool'))->setAllowedTypes('previewFilter', array('string', 'null')); }
public function buildView(FormView $view, FormInterface $form, array $options) { parent::buildView($view, $form, $options); $view->vars['labelAdd'] = $options['labelAdd']; $view->vars['labelDelete'] = $options['labelDelete']; $view->vars['prototype_name'] = $options['prototype_name']; }
/** * {@inheritDoc} */ public function setDefaultOptions(OptionsResolverInterface $resolver) { parent::setDefaultOptions($resolver); $resolver->setRequired(array('root')); $resolver->setOptional(array('create_in_overlay', 'edit_in_overlay', 'delete_in_overlay')); $resolver->setDefaults(array('create_in_overlay' => true, 'edit_in_overlay' => true, 'delete_in_overlay' => true)); }
public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); $countries = Intl::getRegionBundle()->getCountryNames(); // add your custom field $builder->add('email', 'email', array('label' => 'form.email', 'translation_domain' => 'FOSUserBundle'))->add('username', null, array('label' => 'form.username', '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('lastname', 'text')->add('firstname', 'text')->add('image', new AetImageType())->add('pays', 'country', array('expanded' => false, 'multiple' => false))->add('matricule', 'text')->add('whoami', 'textarea', array('required' => false))->add('ville', 'text')->add('code_postale', 'text')->add('telephone', 'text')->add('activite_principale', 'choice', array('choices' => array('Art, Design' => 'Art, Design', 'Audiovisuel - Spectacle' => 'Audiovisuel - Spectacle', 'Audit, gestion' => 'Audit, gestion', 'Automobile' => 'Automobile', 'Banque, assurance' => 'Banque, assurance', 'Bois (filière)' => 'Bois (filière)', 'BTP, architecture' => 'BTP, architecture', 'Chimie, pharmacie' => 'Chimie, pharmacie', 'Commerce, distribution' => 'Commerce, distribution', 'Communication - Marketing, publicité' => 'Communication - Marketing, publicité', 'Construction aéronautique, ferroviaire et navale' => 'Construction aéronautique, ferroviaire et navale', 'Culture - Artisanat d\'art' => 'Culture - Artisanat d\'art', 'Droit, justice' => 'Droit, justice', 'Edition, Journalisme' => 'Edition, Journalisme', 'Électronique' => 'Électronique', 'Énergie' => 'Énergie', 'Enseignement' => 'Enseignement', 'Environnement' => 'Environnement', 'Fonction publique' => 'Fonction publique', 'Hôtellerie, restauration' => 'Hôtellerie, restauration', 'Industrie alimentaire' => 'Industrie alimentaire', 'Informatique, internet et télécom' => 'Informatique, internet et télécom', 'Logistique, transport' => 'Logistique, transport', 'Maintenance, entretien' => 'Maintenance, entretien', 'Mécanique' => 'Mécanique', 'Mode et industrie textile' => 'Mode et industrie textile', 'Recherche' => 'Recherche', 'Santé' => 'Santé', 'Social' => 'Social', 'Sport, loisirs – Tourisme' => 'Sport, loisirs – Tourisme', 'Traduction - interprétariat' => 'Traduction - interprétariat'), 'required' => false, 'mapped' => true))->add('promotion', 'birthday', array('widget' => 'choice', 'years' => range(date('Y') - 110, date('Y')), 'empty_value' => array('year' => '----'))); }
public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); $builder->add('username', 'text', ['label' => 'Username', 'required' => true, 'attr' => ['title' => 'Username must be at least 4 characters long and can only contain letters, numbers, and underscores.'], 'constraints' => [new NotBlank()], 'error_type' => 'inline'])->add('plainPassword', 'password', ['label' => 'Password', 'required' => true, 'attr' => ['title' => 'Password must be at least 8 characters long'], 'error_type' => 'inline', 'validation_groups' => ['Registration']])->add('email', 'repeated', ['type' => 'email', 'first_options' => ['label' => 'E-mail'], 'second_options' => ['label' => 'Confirm E-mail'], 'invalid_message' => 'E-mail and Confirm E-mail do not match', 'required' => true, 'constraints' => [new NotBlank(), new Email()], 'error_type' => 'inline']); /** @var $property ProfileProperty */ foreach ($this->propertyRefs as $property) { $extra = []; if ($property->getName() == 'BirthDay') { $extra = ['title' => 'Must be 18 years old or older', 'constraints' => [new Birthday()]]; } $property->createFormElement($builder, false, $extra); } /* ->add('firstName', null, ['label' => 'First Name', 'required' => true, 'mapped' => false]) ->add('lastName', null, ['label' => 'Last Name', 'required' => true, 'mapped' => false]) ->add('birthday', 'date', [ 'label' => 'Birthday', 'years' => range(date('Y') - 10, date('Y') - 100), 'mapped' => false, ]) ->add('country', 'country', ['preferred_choices' => ['US'], 'mapped' => false]) ->add('preferredLanguage', 'choice', [ 'label' => 'Language', 'choices' => ['en' => 'English', 'es' => 'Spanish', 'pt' => 'Portuguese'], 'required' => true, 'mapped' => false, ]) ; */ }
/** * Builds the form. * * This method is called for each type in the hierarchy starting form the * top most type. Type extensions can further modify the form. * * @param FormBuilderInterface $builder The form builder * @param array $options The options * * @see FormTypeExtensionInterface::buildForm() */ public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); $builder->add('url', 'urlchooser', array('required' => true)); $builder->add('text', 'text', array('required' => true)); $builder->add('openInNewWindow', 'checkbox', array('required' => false)); }
public function buildView(FormView $view, FormInterface $form, array $options) { parent::buildView($view, $form, $options); $view->vars['label'] = false; $view->vars['attr'] = array(); $view->vars['label_attr'] = array(); }
/** * {@inheritdoc} */ public function setDefaultOptions(OptionsResolverInterface $resolver) { parent::setDefaultOptions($resolver); $resolver->setRequired(array('referenced_class')); $resolver->setOptional(array('key')); $resolver->setDefaults(array('key' => ReferenceManyCollectionToArrayTransformer::KEY_UUID)); }
/** * Builds the form. * * This method is called for each type in the hierarchy starting form the * top most type. Type extensions can further modify the form. * * @param FormBuilderInterface $builder The form builder * @param array $options The options * * @see FormTypeExtensionInterface::buildForm() */ public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); $builder->add('title', 'text', array('required' => false)); $builder->add('description', 'wysiwyg', array('required' => false)); $builder->add('icon', 'choice', array('required' => true, 'choices' => ['code' => 'Code', 'wrench' => 'Wrench'])); }
public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); $em = $options['em']; $goalTransformer = new GoalToIdTransformer($em); $builder->add($builder->create('goal', 'hidden', array('required' => false))->addModelTransformer($goalTransformer))->add('parent', null, array('required' => false))->add('name', 'text', array('label' => 'action.task.create_new'))->add('add', 'submit', array('label' => 'common.add')); }
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder, array $options) { $firstDayOfThisMonth = new \DateTime('first day of this month'); $lastDayOfThisMonth = new \DateTime('last day of this month'); $builder->add('dateFrom', TextType::class, array('label' => 'Date from', 'required' => false, 'data' => $firstDayOfThisMonth->format('d.m.Y')))->add('dateTo', TextType::class, array('label' => 'Date to', 'required' => false, 'data' => $lastDayOfThisMonth->format('d.m.Y')))->add('reportType', ChoiceType::class, array('label' => 'Report type', 'choices' => ['Staff' => 1, 'Customer' => 2, 'Individual' => 3], 'attr' => array('class' => 'select2'), 'choices_as_values' => true))->add('project', EntityType::class, array('label' => 'Project', 'class' => 'Admin\\FrontendBundle\\Entity\\Project', 'attr' => array('class' => 'select2'), 'required' => false, 'multiple' => true))->add('customer', EntityType::class, array('label' => 'Customer', 'class' => 'Admin\\FrontendBundle\\Entity\\Customer', 'attr' => array('class' => 'select2'), 'required' => false))->add('staff', EntityType::class, array('label' => 'Staff', 'class' => 'Admin\\FrontendBundle\\Entity\\Staff', 'attr' => array('class' => 'select2'), 'required' => false))->add('payType', EntityType::class, array('label' => 'Pay type', 'class' => 'Admin\\FrontendBundle\\Entity\\AttendancePayType', 'attr' => array('class' => 'select2'), 'required' => false))->add('export', SubmitType::class, array('label' => 'Export to CSV', 'attr' => array('class' => 'btn btn-sm btn-info')))->add('submit', SubmitType::class, array('label' => 'Search', 'attr' => array('class' => 'btn btn-sm btn-primary'))); parent::buildForm($builder, $options); }
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); $builder->add('intTypeOfPerson', 'choice', array('choices' => LenderCreator::GetTypesOfPersonToDropDown(), 'expanded' => true, 'multiple' => false, 'data' => $this->getUser()->getTypeOfPerson())); /** * LEWA STRONA */ $builder->add('strFirstNameNatural', 'text', array('required' => false, 'attr' => array('placeholder' => 'Imię', 'data-required' => 'true'))); $builder->add('strSecondNameNatural', 'text', array('required' => false, 'attr' => array('placeholder' => 'Drugie imię', 'data-required' => 'false'))); $builder->add('strLastNameNatural', 'text', array('required' => false, 'attr' => array('placeholder' => 'Nazwisko', 'data-required' => 'true'))); $builder->add('strPeselNatural', 'text', array('required' => false, 'attr' => array('placeholder' => 'PESEL', 'data-required' => 'true'))); $builder->add('strIdNumberNatural', 'text', array('required' => false, 'attr' => array('placeholder' => 'Nr dowodu osobistego', 'data-required' => 'true'))); $builder->add('strAddressNatural', 'text', array('required' => false, 'attr' => array('placeholder' => 'Adres zamieszkania', 'data-required' => 'true'))); $builder->add('strPostCodeNatural', 'text', array('required' => false, 'attr' => array('placeholder' => 'Kod pocztowy', 'data-required' => 'true'))); $builder->add('strCityNatural', 'text', array('required' => false, 'attr' => array('placeholder' => 'Miescowość', 'data-required' => 'true'))); $builder->add('strPhoneNatural', 'text', array('required' => false, 'attr' => array('placeholder' => 'Telefon', 'data-required' => 'true'))); /** * PRAWA STRONA */ $builder->add('strNameOfCorporationLegal', 'text', array('required' => false, 'attr' => array('placeholder' => 'Nazwa firmy', 'data-required' => 'true'))); $builder->add('strRepresentativeLegal', 'text', array('required' => false, 'attr' => array('placeholder' => 'Reprezentant', 'data-required' => 'true'))); $builder->add('strKrsOrEdgLegal', 'text', array('required' => false, 'attr' => array('placeholder' => 'KRS lub nr wpisu EDG', 'data-required' => 'true'))); $builder->add('strNipLegal', 'text', array('required' => false, 'attr' => array('placeholder' => 'NIP', 'data-required' => 'true'))); $builder->add('strRegonLegal', 'text', array('required' => false, 'attr' => array('placeholder' => 'REGON', 'data-required' => 'true'))); $builder->add('strAddressLegal', 'text', array('required' => false, 'attr' => array('placeholder' => 'Adres siedziby', 'data-required' => 'true'))); $builder->add('strPostCodeLegal', 'text', array('required' => false, 'attr' => array('placeholder' => 'Kod pocztowy', 'data-required' => 'true'))); $builder->add('strCityLegal', 'text', array('required' => false, 'attr' => array('placeholder' => 'Miescowość', 'data-required' => 'true'))); $builder->add('strPhoneLegal', 'text', array('required' => false, 'attr' => array('placeholder' => 'Telefon', 'data-required' => 'true'))); $builder->add('username', 'text', array('attr' => array('placeholder' => 'nick'), 'data' => $this->getUser()->getUsername())); $builder->add('email', 'text', array('attr' => array('placeholder' => 'e-mail'), 'data' => $this->getUser()->getEmail())); $builder->add('password', 'password', array('attr' => array('placeholder' => 'hasło'))); $this->setDefault($builder); }
public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); $builder->add('Nombre', null, array('label' => 'Nombre', 'required' => true))->add('Obs', null, array('label' => 'Obs.', 'required' => false))->add('Encargado', 'entity', array('label' => 'Encargado predet.', 'property' => 'NombreVisible', 'class' => 'Yacare\\BaseBundle\\Entity\\Persona', 'query_builder' => function (\Yacare\BaseBundle\Entity\PersonaRepository $er) { return $er->ObtenerQueryBuilderPorRol('ROLE_REQUERIMIENTOS_ENCARGADO'); }, 'required' => false))->add('PermiteAnonimos', new \Tapir\BaseBundle\Form\Type\SiNoType(), array('label' => 'Admite anónimos', 'required' => true)); }
/** * {@inheritdoc} */ public function buildView(FormView $view, FormInterface $form, array $options) { $view->vars['dataSrc'] = $this->getDataSrc(); $view->vars['lookaheadId'] = $options['lookahead_id']; $view->vars['lateInit'] = $options['late_init']; parent::buildView($view, $form, $options); }
/** * @param \Symfony\Component\OptionsResolver\OptionsResolverInterface $resolver * * @return void */ public function setDefaultOptions(OptionsResolverInterface $resolver) { parent::setDefaultOptions($resolver); $resolver->setRequired('action'); $resolver->setRequired('fields'); $resolver->setDefaults(['attr' => ['class' => 'form-inline']]); }
/** * {@inheritdoc} */ public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); if (!$options['expanded']) { throw new LogicException('The option "expanded" cannot the set to false, use the choice field instead.'); } }
public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); $builder->add('nombrePsaude', 'entity', array('class' => 'EntityBundle:ProblemasSaude', 'multiple' => true, 'required' => false)); /*->add('paciente_problemassaude', 'collection', array( 'type' => new \Paciente_ProblemasSaudeType(), //'label' => 'Orden Responsavels', 'by_reference' => false, 'required' => false //'prototype_data' => new \EntityBundle\Entity\Orden_Responsavel() //'allow_delete' => true, //'allow_add' => true, //'attr' => array( // 'class' => 'row addresses' //) ));*/ //->add('nome1', 'text') //->add('ocupacao1') //->add('telefContato1', 'text', array('label' => 'Telef de Contato')) //->add('email1', 'email'); /*->add('ordenresponsavels', 'collection', array( 'type' => new OneResponsavelType(), //'label' => 'Direcciones', 'by_reference' => false, 'allow_delete' => true, 'allow_add' => true, ))*/ // ->add('nome1', 'text') // ->add('ocupacao1') // ->add('telefContato1', 'text', array('label' => 'Telef de Contato')) //->add('email1', 'email'); }