Next major version 2 with PHP 8.1, Symfony 6, Tabler UI, 2FA ... (#2902)
This commit is contained in:
@@ -10,7 +10,9 @@
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Customer;
|
||||
use App\Form\Type\InvoiceTemplateType;
|
||||
use App\Form\Type\MailType;
|
||||
use App\Form\Type\TeamType;
|
||||
use App\Form\Type\TimezoneType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CountryType;
|
||||
@@ -26,86 +28,108 @@ class CustomerEditForm extends AbstractType
|
||||
{
|
||||
use EntityFormTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$isNew = false;
|
||||
|
||||
if (isset($options['data'])) {
|
||||
/** @var Customer $customer */
|
||||
$customer = $options['data'];
|
||||
$isNew = $customer->getId() === null;
|
||||
$options['currency'] = $customer->getCurrency();
|
||||
}
|
||||
|
||||
$builder
|
||||
->add('name', TextType::class, [
|
||||
'label' => 'label.name',
|
||||
'label' => 'name',
|
||||
'attr' => [
|
||||
'autofocus' => 'autofocus'
|
||||
],
|
||||
])
|
||||
->add('number', TextType::class, [
|
||||
'label' => 'label.number',
|
||||
'label' => 'number',
|
||||
'required' => false,
|
||||
])
|
||||
->add('comment', TextareaType::class, [
|
||||
'label' => 'label.description',
|
||||
'label' => 'description',
|
||||
'required' => false,
|
||||
])
|
||||
->add('company', TextType::class, [
|
||||
'label' => 'label.company',
|
||||
'label' => 'company',
|
||||
'required' => false,
|
||||
])
|
||||
->add('vatId', TextType::class, [
|
||||
'label' => 'label.vat_id',
|
||||
'label' => 'vat_id',
|
||||
'required' => false,
|
||||
])
|
||||
->add('contact', TextType::class, [
|
||||
'label' => 'label.contact',
|
||||
'label' => 'contact',
|
||||
'required' => false,
|
||||
])
|
||||
->add('address', TextareaType::class, [
|
||||
'label' => 'label.address',
|
||||
'label' => 'address',
|
||||
'required' => false,
|
||||
])
|
||||
->add('country', CountryType::class, [
|
||||
'label' => 'label.country',
|
||||
'label' => 'country',
|
||||
])
|
||||
->add('currency', CurrencyType::class, [
|
||||
'label' => 'label.currency',
|
||||
'label' => 'currency',
|
||||
])
|
||||
->add('phone', TelType::class, [
|
||||
'label' => 'label.phone',
|
||||
'label' => 'phone',
|
||||
'required' => false,
|
||||
'block_prefix' => 'phone',
|
||||
])
|
||||
->add('fax', TelType::class, [
|
||||
'label' => 'label.fax',
|
||||
'label' => 'fax',
|
||||
'required' => false,
|
||||
'attr' => ['icon' => 'fax'],
|
||||
'block_prefix' => 'phone',
|
||||
])
|
||||
->add('mobile', TelType::class, [
|
||||
'label' => 'label.mobile',
|
||||
'label' => 'mobile',
|
||||
'required' => false,
|
||||
'attr' => ['icon' => 'mobile'],
|
||||
'block_prefix' => 'phone',
|
||||
])
|
||||
->add('email', MailType::class, [
|
||||
'required' => false,
|
||||
])
|
||||
->add('homepage', UrlType::class, [
|
||||
'label' => 'label.homepage',
|
||||
'label' => 'homepage',
|
||||
'required' => false,
|
||||
'block_prefix' => 'homepage',
|
||||
])
|
||||
->add('timezone', TimezoneType::class, [
|
||||
'label' => 'label.timezone',
|
||||
]);
|
||||
'label' => 'timezone',
|
||||
])
|
||||
->add('invoiceText', TextareaType::class, [
|
||||
'label' => 'invoiceText',
|
||||
'help' => 'help.invoiceText',
|
||||
'required' => false,
|
||||
])
|
||||
->add('invoiceTemplate', InvoiceTemplateType::class, [
|
||||
'help' => 'help.invoiceTemplate_customer',
|
||||
'required' => false,
|
||||
])
|
||||
;
|
||||
|
||||
if ($isNew) {
|
||||
$builder
|
||||
->add('teams', TeamType::class, [
|
||||
'required' => false,
|
||||
'multiple' => true,
|
||||
'expanded' => false,
|
||||
'by_reference' => false,
|
||||
'help' => 'help.teams',
|
||||
]);
|
||||
}
|
||||
|
||||
$this->addCommonFields($builder, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Customer::class,
|
||||
|
||||
Reference in New Issue
Block a user