ProfileType.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace App\Form;
  3. use App\Config\View;
  4. use App\Entity\Profile;
  5. use Symfony\Component\Form\AbstractType;
  6. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  7. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  8. use Symfony\Component\Form\FormBuilderInterface;
  9. use Symfony\Component\OptionsResolver\OptionsResolver;
  10. class ProfileType extends AbstractType
  11. {
  12. public function buildForm(FormBuilderInterface $builder, array $options): void
  13. {
  14. $builder
  15. ->add('view', ChoiceType::class, [
  16. 'expanded' => true,
  17. 'multiple' => false,
  18. 'choices' => [
  19. 'Liste' => View::TABLEAU,
  20. 'Vignette' => View::VIGNETTE
  21. ],
  22. 'label_attr' => [
  23. 'class' => 'pt-0'
  24. ]
  25. ])
  26. ->add('save', SubmitType::class, [
  27. 'label' => 'Enregistrer',
  28. 'row_attr' => [
  29. 'class' => 'mb-3'
  30. ]
  31. ])
  32. ;
  33. }
  34. public function configureOptions(OptionsResolver $resolver): void
  35. {
  36. $resolver->setDefaults([
  37. 'data_class' => Profile::class,
  38. ]);
  39. }
  40. }