nineskeletor/src/Form/BlogType.php

42 lines
1.2 KiB
PHP
Raw Normal View History

2023-01-10 11:13:28 +01:00
<?php
namespace App\Form;
2023-02-16 17:03:53 +01:00
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
2023-01-10 11:13:28 +01:00
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
2023-02-16 17:03:53 +01:00
class BlogType extends AbstractType
2023-01-10 11:13:28 +01:00
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
2023-02-16 17:03:53 +01:00
$builder
->add('submit', SubmitType::class, [
2023-01-10 11:13:28 +01:00
'label' => 'Valider',
'attr' => ['class' => 'btn btn-success'],
2023-02-16 17:03:53 +01:00
])
2023-01-10 11:13:28 +01:00
2023-02-16 17:03:53 +01:00
->add('name', TextType::class, [
'label' => 'Titre',
])
2023-01-10 11:13:28 +01:00
2023-02-16 17:03:53 +01:00
->add('blogtype', EntityType::class, [
'label' => 'Type',
'class' => 'App\Entity\Blogtype',
'choice_label' => 'name',
]);
2023-01-10 11:13:28 +01:00
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
2023-02-16 17:03:53 +01:00
'data_class' => 'App\Entity\Blog',
2023-01-10 11:13:28 +01:00
'mode' => 'string',
2023-02-16 17:03:53 +01:00
'blogtype' => 'App\Entity\Blogtype',
2023-01-10 11:13:28 +01:00
]);
}
}