本文整理汇总了PHP中Symfony\Component\Form\FormBuilder::getFormFactory方法的典型用法代码示例。如果您正苦于以下问题:PHP FormBuilder::getFormFactory方法的具体用法?PHP FormBuilder::getFormFactory怎么用?PHP FormBuilder::getFormFactory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Form\FormBuilder
的用法示例。
在下文中一共展示了FormBuilder::getFormFactory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildForm
public function buildForm(FormBuilder $builder, array $options)
{
$factory = $builder->getFormFactory();
// throw new \Exception('El valor de region es '.$regionId);
$builder->add('nombre')->add('apellido');
if (null == $options['data']->getId()) {
$builder->add('login')->add('password', 'password', array('required' => true));
} else {
$builder->add('login', null, array('read_only' => true))->add('password', 'password', array('required' => false));
}
$builder->add('rut')->add('cargo')->add('profesion')->add('especialidades')->add('email')->add('email2')->add('codigoPostal')->add('direccion')->add('telefono')->add('telefono2')->add('celular')->add('empresa')->add('paginaWeb')->add('tipoUsuario', null, array('required' => true, 'preferred_choices' => array(5)));
/*
if (null == $options['data']->getRegion()) {
$builder->add('comuna', null , array('required' => false, 'empty_value' => '...', 'choices' => array()));
} else {
$builder->add('comuna', 'entity', array(
'required' => false,
'class' => 'TipddyMasleadsBundle:Comunas',
'empty_value' => 'Seleccione una comuna',
'query_builder' => function(EntityRepository $repository) use ($regionId) {
return $repository->createQueryBuilder('c')
->where('c.region = :region')
->setParameter('region', $regionId)
->orderBy('c.id', 'ASC');
}));
}
*/
$builder->add('region', null, array('empty_value' => 'Seleccione', 'required' => false));
/* Probando Eventos en Formularios */
$factory = $builder->getFormFactory();
$refreshComuna = function ($form, $region) use($factory) {
$form->add($factory->createNamed('entity', 'comuna', null, array('class' => 'TipddyMasleadsBundle:Comunas', 'empty_value' => $region == null ? '...' : 'Seleccione', 'label' => 'register.comuna.label', 'query_builder' => function (EntityRepository $repository) use($region) {
return $repository->createQueryBuilder('c')->where('c.region = :region')->setParameter('region', $region)->orderBy('c.id', 'ASC');
})));
};
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (DataEvent $event) use($refreshComuna) {
$form = $event->getForm();
$data = $event->getData();
if ($data == null) {
$refreshComuna($form, null);
}
if ($data instanceof Usuarios) {
$refreshComuna($form, $data->getRegion());
}
});
$builder->addEventListener(FormEvents::PRE_BIND, function (DataEvent $event) use($refreshComuna) {
$form = $event->getForm();
$data = $event->getData();
if (array_key_exists('region', $data)) {
$refreshComuna($form, $data['region']);
}
});
}
示例2: array
function it_should_add_rule_event_subscriber(FormBuilder $builder, FormFactoryInterface $factory)
{
$builder->getFormFactory()->willReturn($factory);
$builder->add(Argument::any(), Argument::cetera())->willReturn($builder);
$builder->addEventSubscriber(Argument::type(BuildRuleFormSubscriber::class))->willReturn($builder);
$this->buildForm($builder, array());
}
示例3: array
function it_builds_form_with_proper_fields(FormBuilder $builder, FormFactoryInterface $factory)
{
$builder->getFormFactory()->willReturn($factory);
$builder->addEventSubscriber(Argument::type('Sylius\\Bundle\\TaxonomyBundle\\Form\\EventListener\\BuildTaxonFormSubscriber'))->willReturn($builder);
$builder->add('translations', 'a2lix_translationsForms', Argument::any())->willReturn($builder);
$this->buildForm($builder, array());
}
示例4: array
function it_should_add_rule_event_subscriber(FormBuilder $builder, FormFactoryInterface $factory)
{
$builder->getFormFactory()->willReturn($factory);
$builder->add(Argument::any(), Argument::cetera())->willReturn($builder);
$builder->addEventSubscriber(Argument::type('Sylius\\Bundle\\ShippingBundle\\Form\\EventListener\\BuildRuleFormSubscriber'))->willReturn($builder);
$this->buildForm($builder, array());
}
示例5: array
function it_builds_attribute_types_prototype_and_passes_it_as_argument(FormBuilder $builder, FormFactoryInterface $formFactory)
{
$builder->getFormFactory()->willReturn($formFactory);
$builder->add('attribute', 'sylius_server_attribute_choice', Argument::any())->willReturn($builder);
$builder->addEventSubscriber(Argument::any())->willReturn($builder);
$this->buildForm($builder, array());
}
示例6: array
function it_should_add_build_promotion_action_event_subscriber(FormBuilder $builder, FormFactoryInterface $factory)
{
$builder->getFormFactory()->willReturn($factory);
$builder->add(Argument::any(), Argument::any(), Argument::any())->willReturn($builder);
$builder->addEventSubscriber(Argument::type('Sylius\\Bundle\\PromotionBundle\\Form\\EventListener\\BuildActionFormListener'))->willReturn($builder);
$this->buildForm($builder, array());
}
示例7: buildForm
public function buildForm(FormBuilder $builder, array $options)
{
if ($options['allow_add'] && $options['prototype']) {
$builder->add('$$name$$', $options['type'], array_replace(array('property_path' => false, 'required' => false), $options['options']));
}
$listener = new ResizeFormListener($builder->getFormFactory(), $options['type'], $options['options'], $options['allow_add'], $options['allow_delete']);
$builder->addEventSubscriber($listener)->setAttribute('allow_add', $options['allow_add'])->setAttribute('allow_delete', $options['allow_delete']);
}
示例8:
function it_builds_form_with_proper_fields(FormBuilder $builder, FormFactoryInterface $factory)
{
$builder->getFormFactory()->willReturn($factory);
$builder->addEventSubscriber(Argument::type(BuildTaxonFormSubscriber::class))->shouldBeCalled()->willReturn($builder);
$builder->addEventSubscriber(Argument::type(AddCodeFormSubscriber::class))->shouldBeCalled()->willReturn($builder);
$builder->add('translations', 'sylius_translations', Argument::any())->shouldBeCalled()->willReturn($builder);
$this->buildForm($builder, []);
}
示例9:
function it_builds_form_with_proper_fields(FormBuilder $builder, FormFactoryInterface $factory)
{
$builder->getFormFactory()->willReturn($factory);
$builder->add('name', 'text', Argument::any())->willReturn($builder);
$builder->add('permalink', 'text', Argument::any())->willReturn($builder);
$builder->add('description', 'textarea', Argument::any())->willReturn($builder);
$this->buildForm($builder, []);
}
示例10: buildForm
/**
* Adds a CSRF field to the form when the CSRF protection is enabled.
*
* @param FormBuilder $builder The form builder
* @param array $options The options
*/
public function buildForm(FormBuilder $builder, array $options)
{
if (!$options['csrf_protection']) {
return;
}
// use a low priority so higher priority listeners don't remove the field
$builder->setAttribute('csrf_field_name', $options['csrf_field_name'])->setAttribute('csrf_provider', $options['csrf_provider'])->setAttribute('csrf_intention', $options['intention'])->setAttribute('csrf_factory', $builder->getFormFactory())->addEventSubscriber(new CsrfValidationListener($options['csrf_field_name'], $options['csrf_provider'], $options['intention']));
}
示例11: array
function it_builds_form_with_name_and_permalink_and_description_fields(FormBuilder $builder, FormFactoryInterface $factory)
{
$builder->getFormFactory()->willReturn($factory);
$builder->addEventSubscriber(Argument::type('Sylius\\Bundle\\TaxonomyBundle\\Form\\EventListener\\BuildTaxonFormListener'))->willReturn($builder);
$builder->add('name', 'text', Argument::any())->willReturn($builder);
$builder->add('permalink', 'text', Argument::any())->willReturn($builder);
$builder->add('description', 'text', Argument::any())->willReturn($builder);
$this->buildForm($builder, array());
}
示例12: array
function it_add_form_builder_specified_by_resource_definition(MapBuilder $map, FormBuilder $builder, TextType $resource, FormFactory $factory, FormBuilder $textBuilder)
{
$map->hasResource('resources.resource_text')->willReturn(true);
$map->getResource('resources.resource_text')->shouldBeCalled()->willReturn($resource);
$builder->getFormFactory()->willReturn($factory);
$resource->getFormBuilder($factory)->shouldBeCalled()->willReturn($textBuilder);
$builder->add($textBuilder)->shouldBeCalled();
$this->buildForm($builder, array('resource_key' => 'resources.resource_text'));
}
示例13: buildForm
/**
* Adds a CSRF field to the form when the CSRF protection is enabled.
*
* @param FormBuilder $builder The form builder
* @param array $options The options
*/
public function buildForm(FormBuilder $builder, array $options)
{
if (!$options['csrf_protection']) {
return;
}
$listener = new EnsureCsrfFieldListener($builder->getFormFactory(), $options['csrf_field_name'], $options['intention'], $options['csrf_provider']);
// use a low priority so higher priority listeners don't remove the field
$builder->setAttribute('csrf_field_name', $options['csrf_field_name'])->addEventListener(FormEvents::PRE_SET_DATA, array($listener, 'ensureCsrfField'), -10)->addEventListener(FormEvents::PRE_BIND, array($listener, 'ensureCsrfField'), -10);
}
示例14: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilder $builder, array $options)
{
if ($options['allow_add'] && $options['prototype']) {
$prototype = $builder->create('$$' . $options['prototype_name'] . '$$', $options['type'], $options['options']);
$builder->setAttribute('prototype', $prototype->getForm());
}
$listener = new ResizeFormListener($builder->getFormFactory(), $options['type'], $options['options'], $options['allow_add'], $options['allow_delete']);
$builder->addEventSubscriber($listener)->setAttribute('allow_add', $options['allow_add'])->setAttribute('allow_delete', $options['allow_delete']);
}
示例15: buildForm
public function buildForm(FormBuilder $builder, array $options)
{
$listener = new ResizeFormListener(
$builder->getFormFactory(),
$options['type'],
$options['type_options'],
$options['modifiable']
);
$builder->addEventSubscriber($listener);
}