feat: add forms

QREntities (FORM)

fix: QRCodeMoneyType

nekam zarad
This commit is contained in:
Ondrej Vlach 2024-01-16 20:30:46 +01:00
parent f450e2db43
commit cb24d39930
Signed by: ovlach
GPG Key ID: 4FF1A23B4914DE70
3 changed files with 103 additions and 0 deletions

View File

@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
namespace App\Form\Type;
use App\Entity\QRCode\QRCodeMoney;
use App\Service\CurrencyListerInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
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;
class QRCodeMoneyType extends AbstractType
{
private readonly CurrencyListerInterface $currencyLister;
public function __construct(CurrencyListerInterface $currencyLister) {
$this->currencyLister = $currencyLister;
}
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('amount', NumberType::class)
->add('currency', ChoiceType::class, [
'choices' => array_combine(
iterator_to_array($this->currencyLister->getCurrencies()),
iterator_to_array($this->currencyLister->getCurrencies())
)
]);
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => QRCodeMoney::class,
]);
}
}

View File

@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
namespace App\Form\Type;
use App\Entity\QRCode\QRCodePaymentIdentification;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class QRCodePaymentIdentificationType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('variableSymbol', IntegerType::class, ['required' => false])
->add('specificSymbol', IntegerType::class, ['required' => false])
->add('constantSymbol', IntegerType::class, ['required' => false]);
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => QRCodePaymentIdentification::class,
]);
}
}

View File

@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
namespace App\Form\Type;
use App\Entity\QRCode\QRCode;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
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;
class QRCodeType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('iban', TextType::class)
->add('dueDate', DateType::class)
->add('message', TextType::class)
->add('money', QRCodeMoneyType::class)
->add('paymentIdentification', QRCodePaymentIdentificationType::class)
->add('save', SubmitType::class);
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => QRCode::class,
]);
}
}