Custom Payment Method field validation in Admin
-
I implemented new payment methods through a custom package and added additional fields into Admin for this method through
packages/Company/Package/Config/system.phpIs it possible to use validation dependent of another field?
For example my payment method has a field of "Merchant ID". This is a required field but only if the method is active. At the moment if i add the 'validation' => 'required' key/value pair to the field, then it is required even if the payment method itself is inactive
-
Hello LemmeV,
within system.php file of your package, you may add type depand so that the field will become dependent on another field. To do so, you have to provide field name and it's option value in depend key, you may have look on below code it will be easier to understand
[
'key' => 'demo.settings.product_price',
'name' => 'demo::app.admin.system.product-price',
'sort' => 3,
'fields' => [
[
'name' => 'price',
'title' => 'demo::app.admin.system.price',
'type' => 'select',
'options' => [
[
'title' => 'demo::app.admin.system.demo',
'value' => 1
], [
'title' => 'demo::app.admin.system.custom-price',
'value' => 2,
]
]
], [
'name' => 'custom_price',
'title' => 'dropship::app.admin.system.custom-price',
'info' => 'dropship::app.admin.system.custom-price-info',
'type' => 'depands',
'depand' => 'price:2',
'validation' => 'required',
'channel_based' => true,
'locale_based' => true
]Thanks