I've added hidden field to shipping section of checkout. If field is visible - validation works, but if I make it hidden - any validation is missing.
Need to prevent going further from shipping to payment by clicking "Next" button and display some error message or alert to user.
Is there way to make this via LayoutProcessor?
Or to extend magento validation in my module for this purpose?
Other versions will be helpful also.
UPD: Maybe this will be helpful for answer. Right now trying to do validation similar to email field at checkout. The idea is next. Create custom form (like email field located inside separate form) and validate it according to this doc http://devdocs.magento.com/guides/v2.0/howdoi/checkout/checkout_form.html#template
<?php
namespace Modules\Deliverydate\Model\Checkout;
class LayoutProcessorPlugin
{
/**
* @param \Magento\Checkout\Block\Checkout\LayoutProcessor $subject
* @param array $jsLayout
* @return array
*/
public function afterProcess(
\Magento\Checkout\Block\Checkout\LayoutProcessor $subject,
array $jsLayout
) {
$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']
['shippingAddress']['children']['shipping-address-fieldset']['children']['delivery_slot'] = [
'component' => 'Magento_Ui/js/form/element/abstract',
'config' => [
'customScope' => 'shippingAddress',
'template' => 'ui/form/field',
// 'elementTmpl' => 'ui/form/element/date',
'options' => [],
'id' => 'enteredSlot'
],
'dataScope' => 'shippingAddress.enteredSlot',
'label' => 'Delivery Slot',
'provider' => 'checkoutProvider',
'visible' => false,
'validation' => [
// 'required-entry' => true,
'validate-no-empty' => true,
],
'sortOrder' => 1,
'id' => 'enteredSlot'
];
return $jsLayout;
}
}