From: Raphaƫl Gertz Date: Wed, 28 Jul 2021 07:19:48 +0000 (+0200) Subject: Add short, rate and nullable description X-Git-Tag: 0.2.4~22 X-Git-Url: https://git.rapsys.eu/airbundle/commitdiff_plain/d5694756a5e86e504fb8165111882bbfa6828d2a?ds=sidebyside Add short, rate and nullable description Add snippet image upload feature --- diff --git a/Form/SnippetType.php b/Form/SnippetType.php index 9c76ff4..0d6fd3b 100644 --- a/Form/SnippetType.php +++ b/Form/SnippetType.php @@ -3,14 +3,18 @@ namespace Rapsys\AirBundle\Form; use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; +use Symfony\Component\Form\Extension\Core\Type\FileType; use Symfony\Component\Form\Extension\Core\Type\HiddenType; -use Symfony\Component\Form\Extension\Core\Type\TextType; +use Symfony\Component\Form\Extension\Core\Type\NumberType; +use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\TextareaType; +use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\UrlType; -use Symfony\Component\Form\Extension\Core\Type\SubmitType; +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; +use Symfony\Component\Validator\Constraints\File; use Symfony\Component\Validator\Constraints\NotBlank; + use Rapsys\AirBundle\Form\Extension\Type\HiddenEntityType; use Rapsys\AirBundle\Entity\Location; use Rapsys\AirBundle\Entity\User; @@ -25,12 +29,15 @@ class SnippetType extends AbstractType { ->add('locale', HiddenType::class, ['required' => true]) ->add('location', HiddenEntityType::class, ['required' => true]) ->add('user', HiddenEntityType::class, ['required' => true]) - ->add('description', TextareaType::class, ['attr' => ['placeholder' => 'Your description', 'cols' => 50, 'rows' => 15], 'constraints' => [new NotBlank(['message' => 'Please provide your description'])], 'required' => true]) - ->add('class', TextareaType::class, ['attr' => ['placeholder' => 'Your class', 'cols' => 50, 'rows' => 15], 'required' => false]) + ->add('description', TextareaType::class, ['attr' => ['placeholder' => 'Your description', 'cols' => 50, 'rows' => 15], 'required' => false]) + ->add('class', TextareaType::class, ['attr' => ['placeholder' => 'Your class', 'cols' => 50, 'rows' => 10], 'required' => false]) + ->add('short', TextareaType::class, ['attr' => ['placeholder' => 'Your short', 'cols' => 50, 'rows' => 10], 'required' => false]) + ->add('rate', NumberType::class, ['attr' => ['placeholder' => 'Your rate'], 'required' => false]) ->add('contact', UrlType::class, ['attr' => ['placeholder' => 'Your contact'], 'required' => false]) ->add('donate', UrlType::class, ['attr' => ['placeholder' => 'Your donate'], 'required' => false]) ->add('link', UrlType::class, ['attr' => ['placeholder' => 'Your link'], 'required' => false]) ->add('profile', UrlType::class, ['attr' => ['placeholder' => 'Your profile'], 'required' => false]) + ->add('image', FileType::class, ['attr' => ['placeholder' => 'Your image'], 'constraints' => [new File(['maxSize' => '5M', 'mimeTypes' => ['image/jpeg', 'image/png', 'image/tiff', 'image/webp'], 'mimeTypesMessage' => 'Please upload a valid Image document'])], 'mapped' => false, 'required' => false]) ->add('submit', SubmitType::class, ['label' => 'Send', 'attr' => ['class' => 'submit']]); }