The below is the full form type class,
cheers
<?php
/**
* Created by PhpStorm.
* Date: 05/09/2015
* Time: 2:59 PM
*/
namespace Atf\Bundle\ScheduleBundle\Form\Type;
// use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormView;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Doctrine\ORM\EntityRepository;
// use Symfony\Component\Security\Core\SecurityContextInterface;
use Oro\Bundle\FormBundle\Utils\FormUtils;
use Oro\Bundle\EmailBundle\Form\Model\Email;
use Oro\Bundle\EmailBundle\Entity\Repository\EmailTemplateRepository;
use Oro\Bundle\SecurityBundle\Authentication\Token\UsernamePasswordOrganizationToken;
use Oro\Bundle\EmailBundle\Form\Type\EmailType as BaseClass;
class ScheduleEmailType extends BaseClass {
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
parent::buildForm($builder, $options);
$builder->add(
'html', 'hidden', array('required' => true)
);
$builder->addEventListener(FormEvents::PRE_SET_DATA, [$this, 'initChoicesByEntityName']);
$builder->addEventListener(FormEvents::PRE_SUBMIT, [$this, 'initChoicesByEntityName']);
}
/**
* @param FormEvent $event
*/
public function initChoicesByEntityName(FormEvent $event)
{
/** @var Email|array $data */
$entityClass = 'Atf\\Bundle\\QuotesBundle\\Entity\\Vehicle';
$form = $event->getForm();
$config = $form->get('template')->getConfig();
$form->add(
'template',
'genemu_jqueryselect2_entity',
array(
'class' => 'Oro\Bundle\EmailBundle\Entity\EmailTemplate',
'property' => 'name',
'label' => 'atf.quotes.branches.branch_type.label'
)
);
}
/**
* {@inheritdoc}
*/
public function getParent()
{
return 'oro_email_email';
}
/**
* {@inheritdoc}
*/
public function getName()
{
return 'atf_schedule_email';
}
}