本文整理汇总了PHP中Symfony\Component\Form\AbstractType类的典型用法代码示例。如果您正苦于以下问题:PHP AbstractType类的具体用法?PHP AbstractType怎么用?PHP AbstractType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AbstractType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: formEncode
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;
}
示例2: doTestSetDefaultOptions
/**
* @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;
}
示例3: getEntityErrorMap
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;
}
示例4: buildForm
/**
* (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));
}
示例5: configureOptions
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
parent::configureOptions($resolver);
if ($this->formType) {
$this->formType->configureOptions($resolver);
}
}
示例6: setDefaultOptions
/**
* @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);
}
示例7: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
parent::buildForm($builder, $options);
if (true === $options['multiple']) {
$builder->addViewTransformer(new CollectionToArrayTransformer(), true);
}
}
示例8: buildForm
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));
}
示例9: buildForm
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'));
}
示例10: finishView
/**
* {@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'];
}
示例11: buildForm
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'));
}
示例12: buildView
/**
* @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'];
}
}
示例13: buildForm
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');
}
示例14: configureOptions
/**
* {@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'));
}
示例15: buildView
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'];
}