J
J
Jan Sokolikovyan2019-05-22 14:36:03
Magento
Jan Sokolikovyan, 2019-05-22 14:36:03

How to override checkout form element template with your own?

I'm trying to change the input field from name="street" for a test, to a regular paragraph. To do this:
1) in the Checkout/view/frontend/web/template folder I create a custom-checkout-form.html file and write to it
5ce53373274d4313863666.png
2) then in the Checkout/view/frontend/web/layout folder I created the checkout_index_index.xml file, in which he wrote

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
    <referenceBlock name="checkout.root">
        <arguments>
            <argument name="jsLayout" xsi:type="array">
                <item name="components" xsi:type="array">
                    <item name="checkout" xsi:type="array">
                        <item name="children" xsi:type="array">
                            <item name="steps" xsi:type="array">
                                <item name="children" xsi:type="array">
                                    <item name="shipping-step" xsi:type="array">
                                        <item name="children" xsi:type="array">
                                            <item name="shippingAddress" xsi:type="array">
                                                <item name="children" xsi:type="array">
                                                    <!-- The name of the form the field belongs to -->
                                                    <item name="shipping-address-fieldset" xsi:type="array">
                                                        <item name="children" xsi:type="array">
                                                            <!--Remove fields-->
                                                            <item name="street" xsi:type="array">
                                                                <item name="config" xsi:type="array">
                                                                    <!-- Assigning a new template -->
                                                                    <item name="component" xsi:type="string">VpLab_Checkout/custom-checkout-form</item>
                                                                </item>
                                                            </item>
                                                        </item>
                                                    </item>
                                                </item>
                                            </item>
                                        </item>
                                    </item>
                                </item>
                            </item>
                        </item>
                    </item>
                </item>
            </argument>
        </arguments>
    </referenceBlock>
</body>

To check if it takes the template from here, I turned off the input, everything worked, with the redefinition - no, thanks in advance!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question