php Symfony-Component-Form-AbstractType类(方法)实例源码

下面列出了php Symfony-Component-Form-AbstractType 类(方法)源码代码实例,从而了解它的用法。

作者:ngyda    项目:CoreBundl   
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;
 }

作者:ramunas    项目:platfor   
/**
  * @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;
 }

作者:scottstuf    项目:GCProtractorJ   
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;
 }

作者:rhapsody-projec    项目:social-bundl   
/**
  * (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));
 }

作者:adam-paterso    项目:orocommerc   
/**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     parent::configureOptions($resolver);
     if ($this->formType) {
         $this->formType->configureOptions($resolver);
     }
 }

作者:spryke    项目:Custome   
/**
  * @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);
 }

作者:webburz    项目:sylius-article-bundl   
/**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     parent::buildForm($builder, $options);
     if (true === $options['multiple']) {
         $builder->addViewTransformer(new CollectionToArrayTransformer(), true);
     }
 }

作者:Rezequie    项目:yacar   
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));
 }

作者:Drake86cn    项目:yacar   
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'));
 }

作者:mapad    项目:typeaheadjs-bundl   
/**
  * {@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'];
 }

作者:alediazr    项目:yacar   
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'));
 }

作者:open-orchestr    项目:open-orchestra-cms-bundl   
/**
  * @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'];
     }
 }

作者:HeliosD    项目:BlogWim   
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');
 }

作者:Lionel0    项目:FormExtensionsBundl   
/**
  * {@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'));
 }

作者:hunter68    项目:hitechonlin   
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'];
 }

作者:Aaik    项目:SonataDoctrinePhpcrAdminBundl   
/**
  * {@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));
 }

作者:AetFranc    项目:SiteFoyerAe   
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' => '----')));
 }

作者:scottstuf    项目:GCProtractorJ   
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,
         ])
     ;
     */
 }

作者:velox    项目:sourcebox-kunstmaa   
/**
  * 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));
 }

作者:scaytras    项目:form-extension   
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();
 }


问题


面经


文章

微信
公众号

扫码关注公众号