<?php
namespace App\Form;
use App\Entity\Parking;
use App\Entity\ParkingMatrixRaw;
use App\Repository\ParkingMatrixRawRepository;
use App\Entity\Days;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\QueryBuilder;
use App\Form\Type\ShareType;
use App\Form\Type\AddressType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Validator\Constraints\File;
class ParkingType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('name')
->add('address', AddressType::class, array('disabled' => false))
->add('type', ShareType::class)
->add('phone')
->add('vehicle')
->add('license_plate')
->add('usage_concent', CheckboxType::class, [
'required' => true,
])
->add('filename', FileType::class, [
'label' => 'Parking (vehicle_image)',
'attr' => array('placeholder' => 'Фото'),
// unmapped means that this field is not associated to any entity property
'mapped' => false,
// make it optional so you don't have to re-upload the PDF file
// every time you edit the Product details
'required' => false,
// unmapped fields can't define their validation using attributes
// in the associated entity, so you can use the PHP constraint classes
'constraints' => [
new File([
'maxSize' => '3000k',
'mimeTypes' => [
'image/*',
],
'mimeTypesMessage' => 'Будь ласка завантажте фото',
])
],
])
->add('comment', TextareaType::class, array(
'attr' => array('cols' => '150', 'rows' => '5', 'placeholder'=> 'Короткий опис'),
))
->add('parkingMatrixRaws', CollectionType::class, array(
'allow_add' => false,
'allow_delete' => false,
'entry_options' => [],
'entry_type' => ParkingMatrixRawType::class
)
);
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Parking::class,
]);
}
}