CustomEmailExtension
3 years ago by idp in PHP
<?php
namespace App\Twig;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* Class CustomEmailExtension
*/
class CustomEmailExtension extends AbstractTypeExtension
{
public static function getExtendedTypes(): iterable
{
return [EmailType::class];
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefined(['symbol']);
}
public function buildView(FormView $view, FormInterface $form, array $options): void
{
$view->vars['symbol'] = $options['symbol'] ?? null;
}
}