Symfony 4.4 Form multiselect bootstrap

I’m trying to change a EntityType form view for something look like: http://davidstutz.de/bootstrap-multiselect/#templates

I make change on my base.html.twig, by adding dependency, I make try bye using code exmaple on this twig file to see if all is fine and it’s working.

Now the problem come when I make change on my _form.html.twig or in the Type.php file, actually after all my try I don’t see where to make change.

My _form.html.twig

  {{ form_start(form) }}
    {{ form_widget(form) }}
    {{ form_widget(form.Service) }}
  <table width=100% cellpadding="10"><tr></tr><tr><td>
    <button class="btn btn-success btn-icon-split">
      <span class="icon text-white-50">
          <i class="fas fa-save"></i>
      </span>
    </button>
  </td>
{{ form_end(form) }}

My UtilisateursType.php

<?php

namespace AppForm;

use AppEntityUtilisateurs;
use AppEntityServices;
use SymfonyComponentFormAbstractType;
use SymfonyComponentFormFormBuilderInterface;
use SymfonyComponentOptionsResolverOptionsResolver;
use SymfonyBridgeDoctrineFormTypeEntityType;
use DoctrineORMEntityRepository;

class UtilisateursType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('Nom')
            ->add('Login')
            ->add('PartagePerso')
            ->add('Service', EntityType::class, [
              'class' => Services::class,
              'query_builder' => function (EntityRepository $Service) {
                return $Service->createQueryBuilder('u')
                ->orderBy('u.Nom', 'ASC');
              },
              'choice_label' => 'Nom',
              'multiple' => true,
              'expanded' => false,
            ])
        ;
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'data_class' => Utilisateurs::class,
        ]);
    }
}

Thank for you help

Source: Symfony Questions

Was this helpful?

0 / 1

Leave a Reply 0

Your email address will not be published. Required fields are marked *