3 namespace Rapsys\AirBundle\Form
;
5 use Symfony\Component\Form\AbstractType
;
6 use Symfony\Component\Form\FormBuilderInterface
;
7 use Symfony\Component\OptionsResolver\OptionsResolver
;
8 #use Symfony\Bridge\Doctrine\Form\Type\EntityType;
9 use Symfony\Component\Form\Extension\Core\Type\HiddenType
;
10 use Symfony\Component\Form\Extension\Core\Type\TextType
;
11 use Symfony\Component\Form\Extension\Core\Type\TextareaType
;
12 use Symfony\Component\Form\Extension\Core\Type\SubmitType
;
13 use Symfony\Component\Validator\Constraints\NotBlank
;
14 use Rapsys\AirBundle\Form\Extension\Type\HiddenEntityType
;
15 use Rapsys\AirBundle\Entity\Location
;
16 use Rapsys\AirBundle\Entity\User
;
17 use Rapsys\AirBundle\Entity\Snippet
;
19 class SnippetType
extends AbstractType
{
23 public function buildForm(FormBuilderInterface
$builder, array $options) {
25 ->add('locale', HiddenType
::class, ['required' => true])
26 ->add('location', HiddenEntityType
::class, ['required' => true])
27 ->add('user', HiddenEntityType
::class, ['required' => true])
28 ->add('description', TextareaType
::class, ['attr' => ['placeholder' => 'Your description', 'cols' => 50, 'rows' => 15], 'constraints' => [new NotBlank(['message' => 'Please provide your description'])], 'required' => true])
29 ->add('submit', SubmitType
::class, ['label' => 'Send', 'attr' => ['class' => 'submit']]);
30 #->add('delete', SubmitType::class, ['label' => 'Remove', 'attr' => ['class' => 'submit']]);
36 public function configureOptions(OptionsResolver
$resolver) {
37 $resolver->setDefaults(['data_class' => Snippet
::class, 'error_bubbling' => true, 'location' => null, 'user' => null]);
38 $resolver->setAllowedTypes('location', [Location
::class, 'null']);
39 $resolver->setAllowedTypes('user', [User
::class, 'null']);
45 public function getName() {
46 return 'snippet_form';