0

I am trying to override checkout_index_index.xml using below code for minimum digits :

<item name="telephone" xsi:type="array">
    <item name="validation" xsi:type="array">
        <item name="min-digits" xsi:type="number">8</item>
    </item>
    <item name="config" xsi:type="array">                                                                          
        <item name="tooltip" xsi:type="array">
            <item name="description" xsi:type="string" translate="true">For delivery questions.</item>                                                    
        </item>
    </item>
</item>

But when I run all the Magento command the rule is not goes performed. Even also I developed a plugin for this :

public function afterMerge(\Magento\Checkout\Block\Checkout\AttributeMerger $subject, $result)
{
    if (array_key_exists('telephone', $result)) {
        $result['telephone']['config']['additionalClasses'] = 'validate-digits';
        $result['telephone']['config']['additionalClasses'] = 'min-digits-8';
        $result['telephone']['additionalClasses'] = 'validate-digits';
        $result['telephone']['additionalClasses'] = 'min-digits-8';
        $result['telephone']['validation']['validate-digits'] = true;
        $result['telephone']['validation']['min-digits'] = 8;
    }

    return $result;
}

But from this also minimum digits validation does not perform. can anyone suggest me which thing i am going to miss ?

I also try to just change the Magento default validation in

<item name="company" xsi:type="array">
    <item name="validation" xsi:type="array">
        <item name="min_text_length" xsi:type="number">5</item>
    </item>
</item>

here I just change from 0 to 5 but still that also not working.

Magento version i used is 2.3.0

0

2 Answers 2

3

no need to deploy code after this just need to clear cache.

checkout_index_index.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="checkout" 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">
                                                            <item name="shipping-address-fieldset" xsi:type="array">
                                                                <item name="children" xsi:type="array">
                                                                    <item name="telephone" xsi:type="array">
                                                                        <item name="validation" xsi:type="array">
                                                                            <item name="min_text_length" xsi:type="number">8</item>
                                                                            <item name="max_text_length" xsi:type="number">8</item>
                                                                            <item name="validate-digits" xsi:type="boolean">true</item>
                                                                        </item>
                                                                    </item>
                                                                </item>
                                                            </item>
                                                        </item>
                                                    </item>
                                                </item>
                                            </item>
                                        </item>
                                    </item>
                                </item>
                            </item>
                        </item>
                    </argument>
                </arguments>
            </referenceBlock>
    </body>
</page>

please check below frontend view.

enter image description here

8
  • ali i try with that solution but that was not working validation is not added at checkout page after deploy the code. Commented Jan 9, 2020 at 12:12
  • 1
    answer updated please check Commented Jan 9, 2020 at 12:17
  • ali can you please let me know the step that after this code which commands you run ? Commented Jan 9, 2020 at 12:19
  • 1
    php bin/magento cache:clean Commented Jan 9, 2020 at 12:20
  • ali i try with that and it's work fine can you just let me know that if we want to change the input type text to input type number then we have to change the default template call <item name="elementTmpl" xsi:type="string">ui/form/element/input</item> so for particular telephone need to change i tried to override that but not working. i put the html fine is VENDOR_MODULE/view/frontend/web/templates/form/elements/telephone.html iset this path but not working infact i remove the input type totally. Commented Jan 9, 2020 at 12:28
0

@hi Saif Ali i found my solution to change the input type text to number through custom module using below code :

VENDOR_MODULE/js/form/element/telephone VENDOR_MODULE/form/element/telephone 8 true

after this remove the cache,generate and do setup upgrade and deploy and it's working.

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.