Bagisto Forum

    Bagisto

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    Custom Payment Method field validation in Admin

    Modules
    2
    2
    707
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • L
      LemmeV last edited by

      I implemented new payment methods through a custom package and added additional fields into Admin for this method through
      packages/Company/Package/Config/system.php

      Is 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
      86c7f4f2-3e32-46f3-9af8-056dc0adb105-image.png

      1 Reply Last reply Reply Quote 0
      • P
        prateek-webkul last edited by

        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

        1 Reply Last reply Reply Quote 0
        • First post
          Last post