OroCRM Forums

Covering OroCRM topics, including community updates and company announcements.

Forums Forums OroCRM OroCRM – Programming Questions Extending EmailType throws 'options' not found

This topic contains 4 replies, has 2 voices, and was last updated by  Alex Taylor 8 years, 6 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #25055

    Alex Taylor
    Participant

    I get the following error:

    Variable "options" does not exist in OroEmailBundle:Form:fields.html.twig at line 126

    When extending the EmailType form from Oro’s Email bundle, however when i remove the entire {% block oro_email_attachments_row %} within fields.html.twig the modal form loads fine.

    Let me know if you need more info.

    Cheers

Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
    Replies
  • #25056

    mccar
    Participant

    Hi,

    Can you provide the extended EmailType class?

    #25057

    Alex Taylor
    Participant

    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';
    }
    }

    #25058

    mccar
    Participant

    Hi

    I try reproduce you problem but can not do it. Can you provide addition how you define this form in services and how do you use this extended form?
    Additional you should remove parent::buildForm() row. You don’t need extend from EmailType class. You can use Symfony\Component\Form\AbstractType to extends.

    #25059

    Alex Taylor
    Participant

    Hi again,

    I extended the email form as to use its modal form functionality; We did it this way in oro 1.3.


    atf.schedule_email.form.type:
    class: %atf.schedule_email.form.type.class%
    arguments:
    - @security.context
    - @oro_email.email_renderer
    - @oro_email.email.model.builder.helper
    tags:
    - { name: form.type, alias: atf_schedule_email }

    This is where it is built in the form.yml file. Essentially I needed to use the EmailType form to create an email form and extend it to add a field for ‘html’ which could be appended to the resulting email to be sent. The html field is filled via javascript.

    Cheers

Viewing 4 replies - 1 through 4 (of 4 total)

The forum ‘OroCRM – Programming Questions’ is closed to new topics and replies.

Back to top