ssossossosso

Forums

Covering OroCRM topics, including community updates and company announcements.  Subscribe

This topic contains 4 replies, has 2 voices, and was last updated by  Alex Taylor 1 year, 11 months ago.

  • Creator
    Topic
  • #13392

    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
  • #13448

    mccar
    Oro Core

    Hi,

    Can you provide the extended EmailType class?

    #13454

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

    #13485

    mccar
    Oro Core

    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.

    #13554

    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)

You must be logged in to reply to this topic.