- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2020
07:19 PM
02-02-2020
07:19 PM
Programmatically add/remove validation based on radio Button choice (checkout)
I have two radio buttons: Private and Business when the user select private button I and to remove the validation from an specific input field: Full name, and if user select private again, it just come it back. Is there a way to programmatically change if the field is required? I added this fields to the checkout using layout processor:
$customField = [ 'component' => 'JCustom_FullName/js/togglepersontype', 'config' => [ 'customScope' => 'shippingAddress', 'template' => 'ui/form/field', 'elementTmpl' => 'JCustom_FullName/radio' ], 'dataScope' => 'shippingAddress' . '.' . $customAttributeCode, 'label' => __('Tipo de entidade:'), 'provider' => 'checkoutProvider', 'sortOrder' => 0, 'validation' => [ 'required-entry' => false ], 'options' => [], 'filterBy' => null, 'customEntry' => null, 'visible' => true, ];
What happens when a field is filled with required-entry => true? Can I change it to false/true using JavaScript?
Labels:
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2020
10:29 PM
02-02-2020
10:29 PM
Re: Programmatically add/remove validation based on radio Button choice (checkout)
Hello @syssolutions
https://devdocs.magento.com/guides/v2.3/ui_comp_guide/concepts/ui_comp_linking_concept.html
please check above link for same.
Hope it will help you
Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer