2

I needed to create configuration form in Magento2 admin. After research, I found that forms had to be defined in xml (system.xml)

    <group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
        <label>Foo Configuration</label>
        <field id="foo2" translate="label" type="text" sortOrder="11" showInDefault="1" showInWebsite="0" showInStore="0">
            <label>Foo Email</label>
            <comment>Defines the foo email.</comment>
            <validate>required-entry validate-email</validate>
        </field>

I found this solution very "clean"

Now I need to make form in frontend, and all examples I find are defining form in phtml files :

like Here

Is there a way to create frontend form in xml also? If yes, What is the best way? If No, Why this difference?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.