Add post and species forms

Squashed commit of the following:
Author: Hugo PRADIER <Hugo.PRADIER2@etu.uca.fr>
Author: bastien ollier <bastien.ollier@etu.uca.fr>
Author: clfreville2 <clement.freville2@etu.uca.fr>
Reviewed on #7
This commit is contained in:
2024-06-07 17:49:12 +02:00
parent 82a3f69fa4
commit 49d60871c9
29 changed files with 740 additions and 86 deletions

38
src/Form/PostType.php Normal file
View File

@@ -0,0 +1,38 @@
<?php
namespace App\Form;
use App\Entity\Post;
use App\Entity\Species;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class PostType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('foundDate', null, [
'widget' => 'single_text',
])
->add('latitude')
->add('longitude')
->add('altitude')
->add('commentary')
->add('species', EntityType::class, [
'class' => Species::class,
'choice_label' => 'scientific_name',
])
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Post::class,
]);
}
}

27
src/Form/SpeciesType.php Normal file
View File

@@ -0,0 +1,27 @@
<?php
namespace App\Form;
use App\Entity\Species;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class SpeciesType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('scientific_name')
->add('vernacular_name')
->add('region')
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Species::class,
]);
}
}