<?php
namespace Products\NotificationsBundle\Form\Forms\Messages;
use Products\NotificationsBundle\Entity\Notifications\Message;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\OptionsResolver;
class MessageTranslationsForm extends AbstractType
{
/**
* {@inheritDoc}
*/
public function finishView(FormView $view, FormInterface $form, array $options): void
{
$view->children['action']->setRendered();
}
/**
* {@inheritDoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$foo = $builder->getData();
$builder
->add('action', HiddenType::class, [
'mapped' => false,
'required' => false,
])
->add('translations', CollectionType::class, [
'entry_type' => MessageTranslationForm::class,
'prototype' => false,
'by_reference' => false,
'entry_options' => [
'label' => false,
],
]);
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => Message::class,
'recordings' => false,
]);
}
}