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:
38
src/Form/PostType.php
Normal file
38
src/Form/PostType.php
Normal 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
27
src/Form/SpeciesType.php
Normal 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,
|
||||
]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user