1

i create a system xml to load a field dropdown for selecting email template, but when i access the configuration page there is an error like this:

Exception #0 (UnexpectedValueException): Email template 'paymentconfirmation_general_payment_confirmation_email' is not defined.

here's my system.xml:

<group id="general" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="10" translate="label">
                <label>Payment Confirmation E-Mail</label>
                <field id="email" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="1" translate="label" type="text">
                    <label>Store E-Mail Receivers</label>
                    <comment>Insert ',' between e-mail addresses</comment>
                </field>
                <field id="payment_confirmation_email" translate="label comment" type="select" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>E-Mail Template</label>
                <source_model>Magento\Config\Model\Config\Source\Email\Template</source_model>
                </field>
            </group>

here's my config.xml:

<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
    <default>
        <paymentconfirmation> 
            <general>
                <email/>
                <payment_confirmation_email/>
            </general>
        </paymentconfirmation>
    </default>
</config>

1 Answer 1

3

Create a email template config.

Vendor/Module/etc/email_templates.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Email:etc/email_templates.xsd">
    <template id="paymentconfirmation_general_payment_confirmation_email" label="Email Form" file="email_template.html" type="text" module="Vendor_Module" area="frontend"/>
</config>

Inside config.xml, change <payment_confirmation_email/> to following

<payment_confirmation_email>paymentconfirmation_general_payment_confirmation_email</payment_confirmation_email>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.