CommentaireType.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace App\Form;
  3. use Symfony\Component\Form\Extension\Core\Type\NumberType;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  6. use Symfony\Component\Form\FormBuilderInterface;
  7. use Symfony\Component\OptionsResolver\OptionsResolver;
  8. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  9. class CommentaireType extends AbstractType
  10. {
  11. /**
  12. * {@inheritdoc}
  13. */
  14. public function buildForm(FormBuilderInterface $builder, array $options)
  15. {
  16. $builder
  17. ->add('note', NumberType::class, array (
  18. 'required' => false,
  19. 'label' => false,
  20. 'attr' => array (
  21. 'min' => 0,
  22. 'max' => 5,
  23. 'class' => "rating",
  24. 'data-step' => 1,
  25. 'data-show-clear' => "true",
  26. 'data-show-caption' => "false",
  27. 'data-size' => "sm",
  28. 'data-theme' => "krajee-fa"
  29. )
  30. ))
  31. ->add('contenu', TextareaType::class, array(
  32. 'required' => false,
  33. 'label' => false
  34. ))
  35. ->add('save', SubmitType::class, array(
  36. 'label' => 'Enregistrer le commentaire',
  37. 'attr'=>array(
  38. 'class' => 'btn-primary'
  39. )));
  40. }
  41. /**
  42. * {@inheritdoc}
  43. */
  44. public function configureOptions(OptionsResolver $resolver)
  45. {
  46. $resolver->setDefaults(array(
  47. 'data_class' => 'App\Entity\Commentaire'
  48. ));
  49. }
  50. /**
  51. * {@inheritdoc}
  52. */
  53. public function getBlockPrefix() : string
  54. {
  55. return 'App_commentaire';
  56. }
  57. }