src/Products/NotificationsBundle/Form/Forms/Messages/MessageTranslationsForm.php line 15

Open in your IDE?
  1. <?php
  2. namespace Products\NotificationsBundle\Form\Forms\Messages;
  3. use Products\NotificationsBundle\Entity\Notifications\Message;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\Extension\Core\Type\CollectionType;
  6. use Symfony\Component\Form\Extension\Core\Type\FormType;
  7. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  8. use Symfony\Component\Form\FormBuilderInterface;
  9. use Symfony\Component\Form\FormInterface;
  10. use Symfony\Component\Form\FormView;
  11. use Symfony\Component\OptionsResolver\OptionsResolver;
  12. class MessageTranslationsForm extends AbstractType
  13. {
  14.     /**
  15.      * {@inheritDoc}
  16.      */
  17.     public function finishView(FormView $viewFormInterface $form, array $options): void
  18.     {
  19.         $view->children['action']->setRendered();
  20.     }
  21.     /**
  22.      * {@inheritDoc}
  23.      */
  24.     public function buildForm(FormBuilderInterface $builder, array $options): void
  25.     {
  26.         $foo $builder->getData();
  27.         $builder
  28.             ->add('action'HiddenType::class, [
  29.                 'mapped' => false,
  30.                 'required' => false,
  31.             ])
  32.             ->add('translations'CollectionType::class, [
  33.                 'entry_type' => MessageTranslationForm::class,
  34.                 'prototype' => false,
  35.                 'by_reference' => false,
  36.                 'entry_options' => [
  37.                     'label' => false,
  38.                 ],
  39.             ]);
  40.     }
  41.     /**
  42.      * {@inheritdoc}
  43.      */
  44.     public function configureOptions(OptionsResolver $resolver)
  45.     {
  46.         $resolver->setDefaults([
  47.             'data_class' => Message::class,
  48.             'recordings' => false,
  49.         ]);
  50.     }
  51. }