Embedding a dynamic form in Symfony2 - forms

General info
I am working with Symfony 2.8. In this question two entities are the subject. ObjectElementTask and Activity. I have embedded Activity as a collection inside ObjectElementTask. So far, everything is fine and up and running.
Problem
I added a evenlistener in ActivityType. Because a part of the ActivityForm inside the ObjectElementTaskForm has to be dynamic (based on the authenticated user that is using the form...)
When I view the ActivityForm direct: through the ActivityController (which calls the form with this code: $editForm = $this->createForm('AppBundle\Form\ActivityType', $activity);) the eventlistener is working.
When I view the ObjectElementTaksForm I get a exception:
Type error: Argument 1 passed to AppBundle\Form\ActivityType::__construct() must implement interface Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface, none given, called in /home/vpcont1q/public_html/test/src/AppBundle/Form/ObjectElementTaskType.php on line 62
My Guess
I guess because inside the ObjectElementTaksForm, the ActivityForm gets called on a other way then inside the ActivityController. And then the argument (registered in the services.yml) doesn't get passed. How to make sure the registered service gets called when embedding the form? Or... am I looking in the wrong direction.
Code
Below my Types and the services.yml part:
This is my ActivityType:
<?php
namespace AppBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormEvent;
class ActivityType extends AbstractType
{
private $tokenStorage;
public function __construct(TokenStorageInterface $tokenStorage)
{
$this->tokenStorage = $tokenStorage;
}
/**
* #param FormBuilderInterface $builder
* #param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('executionDate')
->add('status'),
->add('scheduledDate')
// grab the user, do a quick sanity check that one exists
$user = $this->tokenStorage->getToken()->getUser();
if (!$user) {
throw new \LogicException(
'You are NOT an authenticated user!'
);
}
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($user) {
//TODO
});
}
/**
* #param OptionsResolver $resolver
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'AppBundle\Entity\Activity'
));
}
}
And this is my ObjectElementTaskType:
<?php
namespace AppBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormEvent;
class ObjectElementTaskType extends AbstractType
{
/**
* #param FormBuilderInterface $builder
* #param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('activities', 'collection', array(
'entry_type' => new ActivityType(),
'allow_add' => true,
'allow_delete' => true,
'by_reference' => false,
))
;
}
/**
* #param OptionsResolver $resolver
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'AppBundle\Entity\ObjectElementTask',
));
}
}
I have registered the ActivityForm as a service with the token as a argument:
app.form.activity:
class: AppBundle\Form\ActivityType
arguments: ['#security.token_storage']
tags:
- { name: form.type }
EDIT
This seems to work:
Instead of registering the ActivityType as a service I registered the ObjectElementTask as a service (also with the Tokenstorage).
I don't use the ActivityType other then embedded in the ObjectElementTaskType so that's why I removed the ActivityType as a service in services.yml.
app.form.object_element_task:
class: AppBundle\Form\ObjectElementTaskType
arguments: ['#security.token_storage']
tags:
- { name: form.type }
And in the ObjectElementTaskType I added the construct:
<?php
namespace AppBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormEvent;
class ObjectElementTaskType extends AbstractType
{
private $tokenStorage;
public function __construct(TokenStorageInterface $tokenStorage)
{
$this->tokenStorage = $tokenStorage;
}
/**
* #param FormBuilderInterface $builder
* #param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$tokenStorage = $this->tokenStorage;
And in the buildform I added the tokenstorage as a parameter in the ActivityType class declaration:
->add('activities', 'collection', array(
'entry_type' => new ActivityType($tokenStorage),
'allow_add' => true,
'allow_delete' => true,
'by_reference' => false,
))
The ActivityType I haven't changed. Is this a workaround or the way to do it?

Related

Variable "form" does not exist. Symfony 4

I am new to Symfony 4 and I am following this tutorial "https://symfony.com/doc/4.4/forms.html" but it does not recognize my variable "form" and I don't know why (everything is up to date).
My Controller :
<?php
namespace App\Controller;
use App\Entity\Task;
use App\Form\Type\TaskType;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
class TaskController extends AbstractController
{
public function new(Request $request)
{
// creates a task object and initializes some data for this example
$task = new Task();
$task->setTask('Write a blog post');
$task->setDueDate(new \DateTime('tomorrow'));
/*$form = $this->createFormBuilder($task)
->add('task', TextType::class)
->add('dueDate', DateType::class)
->add('save', SubmitType::class, ['label' => 'Create Task'])
->setMethod('GET')
->getForm();*/
$form = $this->createForm(TaskType::class, $task);
return $this->render('search/search.html.twig', [
'form' => $form->createView(),
]);
}
}
My TaskType.php :
<?php
namespace App\Form\Type;
use App\Entity\Task;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
class TaskType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('task', TextType::class)
->add('dueDate', DateType::class)
->add('save', SubmitType::class);
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => Task::class,
]);
}
}
And my Task.php :
<?php
namespace App\Entity;
class Task
{
protected $task;
protected $dueDate;
public function getTask()
{
return $this->task;
}
public function setTask($task)
{
$this->task = $task;
}
public function getDueDate()
{
return $this->dueDate;
}
public function setDueDate(\DateTime $dueDate = null)
{
$this->dueDate = $dueDate;
}
}
If you see any error from my part I am open..
I am calling my form here :
{{ form_start(form) }}
{{ form(form) }}
{{ form_end(form) }}
In my "search.html.twig".

Bootstrap TagsInput with EntityType dropdown values (Symfony)

I'm making a form to register books (Symfony 4), each with a unique publisher (ManyToOne) and one or many authors (ManyToMany). Both fields are filled in the form as tags, with Bootstrap TagsInput, so that if the user types in those fields, they will suggest the list of values in the DB tables, and if not, the new values will be inserted when submitting, along with the other book data.
I followed the official example of Best Practices on the Symfony website, and the tagging system works for authors, because it's a CollectionType, but not with the publisher, because it's an EntityType. How could I adapt it? Fails to transform publisher values into comma-separated strings so it can be recognized by TagsInput.
Book Entity (App\Entity\Book.php)
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
class Book
{
/**
* #var \Publisher
*
* #ORM\ManyToOne(targetEntity="Publisher", cascade={"persist"})
* #ORM\JoinColumns({
* #ORM\JoinColumn(nullable=false, name="publisher_id", referencedColumnName="id")
* })
*/
private $publisher;
/**
* #var Author[]|ArrayCollection
*
* #ORM\ManyToMany(targetEntity="Author", cascade={"persist"})
* #ORM\JoinTable(name="authors_books")
*/
private $authors;
public function __construct()
{
$this->authors = new ArrayCollection();
}
public function getPublisher()
{
return $this->publisher;
}
public function getAuthors(): Collection
{
return $this->authors;
}
}
Book Form (App\Form\BookType.php)
namespace App\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use App\Form\Type\PublisherType;
use App\Form\Type\AuthorType;
class BookType extends AbstractType {
public function buildForm(FormBuilderInterface $builder, array $options){
$builder
->add('publisher', PublisherType::class, array(
'label' => 'Publisher',
))
->add('authors', AuthorType::class, array(
'label' => 'Author/s'
))
}
}
AuthorType
namespace App\Form\Type;
use Symfony\Bridge\Doctrine\Form\DataTransformer\CollectionToArrayTransformer;
use App\Form\DataTransformer\AuthorToStringTransformer;
use App\Repository\AuthorRepository;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
class AuthorType extends AbstractType {
private $authors;
public function __construct(AuthorRepository $authors_repo)
{
$this->authors = $authors_repo;
}
public function buildForm(FormBuilderInterface $builder, array $options){
$builder
->addModelTransformer(new CollectionToArrayTransformer(), true)
->addModelTransformer(new AuthorToStringTransformer($this->authors), true)
;
}
public function buildView(FormView $view, FormInterface $form, array $options): void
{
$view->vars['authors'] = $this->authors->findAll();
}
public function getParent()
{
return TextType::class;
}
}
PublisherType
namespace App\Form\Type;
use App\Form\DataTransformer\EntityToArrayTransformer;
use App\Form\DataTransformer\PublisherToStringTransformer;
use App\Repository\PublisherRepository;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
class PublisherType extends AbstractType {
private $publishers;
public function __construct(PublisherRepository $publisher_repo) {
$this->publishers = $publisher_repo;
}
public function buildForm(FormBuilderInterface $builder, array $options) {
$builder
->addModelTransformer(new EntityToArrayTransformer(), true)
->addModelTransformer(new PublisherToStringTransformer($this->publishers), true);
}
public function buildView(FormView $view, FormInterface $form, array $options): void
{
$publishers = $this->publishers->findAll();
}
public function getParent()
{
return TextType::class;
}
}
CollectionToArrayTransformer
namespace Symfony\Bridge\Doctrine\Form\DataTransformer;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Form\DataTransformerInterface;
class CollectionToArrayTransformer implements DataTransformerInterface
{
public function transform($collection)
{
if (null === $collection) {
return [];
}
if (\is_array($collection)) {
return $collection;
}
return $collection->toArray();
}
}
EnityToArrayTransformer
namespace App\Form\DataTransformer;
use Symfony\Component\Form\DataTransformerInterface;
class EntityToArrayTransformer implements DataTransformerInterface
{
public function transform($entity)
{
if (null === $entity) {
return [];
}
return [$entity];
}
}
AuthorToStringTransformer
namespace App\Form\DataTransformer;
use App\Entity\Author;
use App\Repository\AuthorRepository;
use Symfony\Component\Form\DataTransformerInterface;
class AuthorToStringTransformer implements DataTransformerInterface
{
private $authors;
public function __construct(AuthorRepository $authors)
{
$this->authors = $authors;
}
public function transform($authors): string
{
/* #var Author[] $authors */
return implode(',', $authors);
}
public function reverseTransform($string): array
{
...
}
}
PublisherToStringTransformer
namespace App\Form\DataTransformer;
use App\Entity\Publisher;
use App\Repository\PublisherRepository;
use Symfony\Component\Form\DataTransformerInterface;
class PublisherToStringTransformer implements DataTransformerInterface
{
private $publishers;
public function __construct(PublisherRepository $publishers)
{
$this->publishers = $publishers;
}
public function transform($publisher): string
{
/* #var Publisher[] $publisher */
return implode(',', $publisher);
}
public function reverseTransform($publisher): string
{
...
}
}
Form Twig
{{ form_widget(form.publisher, {'attr': {'class': class, 'data-toggle': 'tagsinput', 'data-publishers': form.publisher.vars.publishers|json_encode } }) }}
{{ form_widget(form.publisher, {'attr': {'class': class, 'data-toggle': 'tagsinput', 'data-authors': form.publisher.vars.authors|json_encode } }) }}
This is the code I use for Editors and Authors, so that you can compare the one that works and the one that doesn't work. They are not so different, but something is wrong, and I don't know what it is or what I need to change.
Ok, I've found a solution. I have made all the changes in both Transformers, because the problem was the format to which I converted the entity and vice versa.

This value should not be blank

I know that could be a noob error, but I wasted a lot of time in this.
I have a entity that modified with a form. This is my entity:
class RetiroResiduo
{
/**
* #ORM\Id
* #ORM\ManyToOne(targetEntity="GestionResiduos\SolicitudRetiroBundle\Entity\SolicitudRetiro")
* #ORM\JoinColumn(name="numeroSolicitudRet_id", onDelete="CASCADE", referencedColumnName="numeroSolicitudRet")
*/
protected $numeroSolicitudRet;
/**
* #ORM\Id
* #ORM\ManyToOne(targetEntity="GestionResiduos\ResiduoBundle\Entity\Residuo")
* #ORM\JoinColumn(name="siglaRepresentativa_id", onDelete="CASCADE",referencedColumnName="siglaRepresentativa")
*/
protected $siglaRepresentativa;
/**
* #ORM\ManyToOne(targetEntity="GestionResiduos\ResiduoBundle\Entity\Contenedor")
* #ORM\JoinColumn(name="nombreContenedor_id", onDelete="CASCADE", referencedColumnName="nombreContenedor")
*/
protected $nombreContenedor;
...
}
This entity is handled with this form:
<?php
// src/Gestionresiudos/SolicitudRetiroBundle/Form/SolicitudRetiroType.php
namespace Gestionresiduos\SolicitudRetiroBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class RetiroResiduoType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('siglaRepresentativa')
->add('nombreContenedor')
->add('cantidadContenedores')
->add('peso')
->add('volumen')
->add('solicitar', 'submit')
->add('addotro', 'submit')
;
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'Gestionresiduos\SolicitudRetiroBundle\Entity\RetiroResiduo',
'cascade_validation' => true,
));
}
public function getName()
{
return 'retiroresiduo';
}
}
my action into my controller look like:
public function RetirarResiduoAction($idsol, Request $request)
{
$numSolRetiro = $idsol;
$residuoARetirar = new RetiroResiduo();
//echo gettype($residuoARetirar);
$formulario = $this->createForm(new RetiroResiduoType(), $residuoARetirar);
$formulario->handleRequest($request);
if ($formulario->isValid())
{
....
}
...
}
This is my form into view:
{{ form_start(formulario, {'attr': {'class': 'form-horizontal'}})}}
{{ form_errors(formulario)}}
{{ form_rest(formulario) }}
{{ form_end(formulario)}}
Finally I give you a print from the error to give my interface.
As you can see when I send my form doesn't enter into if(formulario->isvalid()). Obviously, I selected one option into choice. I saw similar questions but don't working for me. I need some advice or something that help me with this bug.
Note: I know that problem should be into my entity but I still don't see.
NOTE2: I'm using symfony2.3

Symfony2 Entity Form Type gets data from another Entity

I have 2 entities: Audio and Destination
In Audio:
/**
* #ORM\OneToOne(targetEntity="HearWeGo\HearWeGoBundle\Entity\Destination", inversedBy="audio")
* #Assert\NotBlank(message="This field must be filled")
*
*/
private $destination;
I created a Form Type name EditAudioType used to edit an audio whose uploaded link is stored in database
<?php
namespace HearWeGo\HearWeGoBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use HearWeGo\HearWeGoBundle\Entity\Audio;
class AudioAudioType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$destination_repo=$options['dr'];
$builder
->add('name','text')
->add('audio','file')
->add('destination','entity',array(
'class'=>'HearWeGoHearWeGoBundle:Destination',
'choices'=>$destination_repo->findToReplaceAudio('id'),
'property'=>'name'
));
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array('data_class'=>"HearWeGo\\HearWeGoBundle\\Entity\\Audio"));
$resolver->setRequired(array('dr'));
}
public function getName()
{
return 'edit_audio';
}
}
I did as the similar answer in my old post:
Symfony2 Entity Form Type gets data
But now I don't know what I will put in choices attribute of form, because this custom repo function has parameter, not like the old answer. In DestinationRepository:
public function findByAudioId($id)
{
return $this->getEntityManager()->createQuery('SELECT d FROM HearWeGoHearWeGoBundle:Destination d,HearWeGoHearWeGoBundle:Audio a WHERE d.id=IDENTITY (a.destination)')->getResult();
}
public function findToReplaceAudio($id)
{
$result=$this->findDestinationWithoutAudio();
$result[]=$this->findByAudioId($id);
return $result;
}
I'll do something like :
<?php
namespace HearWeGo\HearWeGoBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use HearWeGo\HearWeGoBundle\Entity\Audio;
use HearWeGo\HearWeGoBundle\Entity\Repository\AudioRepository;
class AudioAudioType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('name','text')
->add('audio','file')
->add('destination','entity',array(
'class'=>'HearWeGoHearWeGoBundle:Destination',
'query_builder'=>function (AudioRepository $repository) {
return $repository->findToReplaceAudioQueryBuilder('id');
},
'property' => 'name'
));
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array('data_class'=>"HearWeGo\\HearWeGoBundle\\Entity\\Audio"));
}
public function getName()
{
return 'edit_audio';
}
}
Please have a look to the official documentation.

Symfony2: Adding a collection based on a table-inheritance structure to a FormView

I am working on a Symfony2/Doctrine app which uses class-table-inheritance (http://docs.doctrine-project.org/en/2.0.x/reference/inheritance-mapping.html#class-table-inheritance) to manage Complaints in a Consult. Each Consult can have many Complaints (OneToMany), and each different type of Complaint has a different structure and appearance. Complaints are a collection and are added dynamically with JS.
At this point, I am able to persist the Complaints and link them to the Consults by recasting them as the appropriate types in the Controller before persistence. I have run into some issues with this and I'm planning on migrating this to a form event (http://symfony.com/doc/current/cookbook/form/dynamic_form_generation.html) or something of that nature to streamline the process.
The problem that I am running into at this point, however, is that I am unable to display existing Complaints in a view using the FormView because the form builder demands that I set the type of the collection to be displayed. If each Consult had only one type of Complaint, that would be fine, but they can have multiple types, and setting the type in the form builder limits me to that one type.
Is there some approach that I can take to stop the FormView from tyring to convert to string in the absence of a type or some way to dynamically detect and assign the type on a per-Complaint basis (using $complaint->getComplaintType(), perhaps)?
<?php
namespace Acme\ConsultBundle\Entity;
class Consult
{
/**
* #ORM\OneToMany(targetEntity="Acme\ConsultBundle\Entity\ComplaintBase", mappedBy="consult", cascade={"persist", "remove"})
*/
protected $complaints;
}
?>
<?php
namespace Acme\ConsultBundle\Entity;
/**
* Acme\ConsultBundle\Entity\ConsultBase
*
* #ORM\Entity
* #ORM\Table(name="ConsultComplaintBase")
* #ORM\HasLifecycleCallbacks
* #ORM\InheritanceType("JOINED")
* #ORM\DiscriminatorColumn(name="complaint_name", type="string")
* #ORM\DiscriminatorMap({
* "ComplaintDefault" = "Acme\ConsultBundle\Entity\ComplaintDefault",
* "ComplaintRosacea" = "Acme\ConsultBundle\Entity\ComplaintRosacea",
* "ComplaintBotox" = "Acme\ConsultBundle\Entity\ComplaintBotox",
* "ComplaintAcne" = "Acme\ConsultBundle\Entity\ComplaintAcne",
* "ComplaintUrticaria" = "Acme\ConsultBundle\Entity\ComplaintUrticaria",
* })
*/
abstract class ComplaintBase
{
/**
* #ORM\ManyToOne(targetEntity="Acme\ConsultBundle\Entity\Consult", inversedBy="complaints")
* #ORM\JoinColumn(name="consult_id", referencedColumnName="id")
*/
protected $consult;
/**
* #ORM\Column(type="string", length="255")
*/
protected $complaintType;
}
?>
<?php
namespace Acme\ConsultBundle\Form\Type;
class ConsultType extends AbstractType
{
public function buildForm(FormBuilder $builder, array $options)
{
$builder
->add('complaints', 'collection', array(
// 'type' => new ComplaintUrticariaType(),
'error_bubbling' => true,
'allow_add' => true,
'allow_delete' => true,
'by_reference' => false,
));
}
}
?>
Not exactly sure that it will work with the collection, but it certainly works with a single form. Please try this idea.
First make a form for your basic entity ComplaintBase
class ComplaintForm extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$subscriber = new ComplaintSubscriber($builder);
$builder->addEventSubscriber($subscriber);
/* your fields */
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'Acme\ConsultBundle\Entity\ComplaintBase',
));
}
}
Then in subscriber you can define additional fields based on submitted entity type.
class ComplaintSubscriber implements EventSubscriberInterface
{
private $factory;
private $builder;
public function __construct(FormBuilderInterface $builder)
{
$this->factory = $builder->getFormFactory();
$this->builder = $builder;
}
public static function getSubscribedEvents()
{
return array(
FormEvents::PRE_SET_DATA => 'preSetData',
);
}
public function preSetData(FormEvent $event)
{
$data = $event->getData();
$form = $event->getForm();
if (null === $data) {
return;
}
$class = get_class($data);
if( $class === 'Acme\ConsultBundle\Entity\ComplaintDefault' ) {
$this->processDefault($data, $form);
}
elseif( $class === 'Acme\ConsultBundle\Entity\ComplaintRosacea' ) {
$this->processRosacea($data, $form);
}
elseif( $class === 'Acme\ConsultBundle\Entity\ComplaintBotox' ) {
$this->processBotox($data, $form);
}
else {
#NOP
}
}
protected function processDefault(Entity\ComplaintDefault $node, FormInterface &$form)
{
#NOP
}
protected function processRosacea(Entity\ComplaintRosacea $node, FormInterface &$form)
{
$form->add($this->factory->createNamed('some_field', 'text'));
}
protected function processBotox(Entity\ComplaintBotox $node, FormInterface &$form)
{
$form->add($this->factory->createNamed('other_field', 'text'));
}
}