<?php

namespace App\Form;

use App\Entity\Photo;
use App\Form\DataTransformer\UploadDataTransformer;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

use Symfony\Component\Validator\Constraints as Assert;

class PhotoType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->add('file', FileType::class, [
                'label' => 'Photo',
                'constraints' => [
                    new Assert\File(
                        maxSize: '8192k',
                        extensions: ['jpg', 'png'],
                    ),
                ],
            ])
            ->add('alt_text')
            ->add('date')
            ->add('equipment')
            ->add('location')
            ->add('caption')
        ;

    }

    public function configureOptions(OptionsResolver $resolver): void
    {
        $resolver->setDefaults([
            'data_class' => Photo::class,
        ]);
    }
}
