<?php
namespace App\Form;
use App\Entity\Newsletter;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
class NewsletterType extends AbstractType
{
protected $router;
public function __construct(UrlGeneratorInterface $router)
{
$this->router = $router;
}
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('name', null, [
"label" => "newsletter_type.name.placeholder",
// "attr" => ["placeholder" => "newsletter_type.name.placeholder"]
])
->add('email', null, [
"label" => "newsletter_type.email.placeholder",
// "attr" => ["placeholder" => "newsletter_type.email.placeholder"]
])
->add("condition", CheckboxType::class, [
"mapped" => false,
"required" => true,
"label_attr" => [
"class" => "fw-400 checkbox-custom"
],
'label' => 'contact_type.condition_label',
'label_translation_parameters' => [
'%url%' => $this->router->generate('front_privacy_policy'),
],
"label_html" => true,
])
->setAction($this->router->generate("front_subscribe_newsletter"));
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Newsletter::class,
]);
}
}