suivi/src/Form/ExpenseReportVariousPaymentType.php
2022-10-30 20:05:40 +01:00

63 lines
1.9 KiB
PHP

<?php
namespace App\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Range;
class ExpenseReportVariousPaymentType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('date', DateType::class, [
'html5' => true,
'required' => true,
'widget' => 'single_text',
'row_attr' => [
'class' => 'col-md-4 pr-1',
],
'constraints' => [
new NotBlank(),
],
])
->add('label', TextType::class, [
'row_attr' => [
'class' => 'col-md-4 pr-1',
],
'constraints' => [
new NotBlank(),
],
])
->add('amount', NumberType::class, [
'required' => true,
'html5' => true,
'row_attr' => [
'class' => 'col-md-4 pr-1',
],
'attr' => [
'step' => 0.01,
],
'scale' => 2,
'constraints' => [
new NotBlank(),
new Range(['min' => 0]),
],
])
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
// Configure your form options here
]);
}
}