Customer Portal

Get Involved. Join the Conversation.


    Sergio Andres Barreto Valderrama
    How to register a mandatory field by selecting a product...
    Topic posted June 4, 2019 by Sergio Andres Barreto ValderramaBronze Medal: 1,250+ Points 
    38 Views, 2 Comments
    How to register a mandatory field by selecting a product type?
    Mandatory Field Selecting a Product type

    Hello team!,

    I need to know how I can achieve that if the client selects a category of a specific product, immediately the field of "attachments" is enabled as mandatory.

    I need this only for five categories, that is, when the client selects one of them, the attachment field becomes mandatory. If, on the other hand, the customer chooses another category, leave the normal "attachment" field.

    I have made the attached field mandatory for all categories, but I need it only for specific categories.

    If anyone knows how to achieve it, I appreciate it!





    • Shiloh Madsen

      You're going to need to use dynamic forms if you want the attributes of one input element to change based on the values of the other inputs. Fortunately the dynamic forms sample code will get you 80-90 percent of the way there. You'll need to grab the source code in the zip file and examine the widgets it extends and how it implements in the example page. From here you should easily see how to alter the implementation page to make your fields aware of the productcategoryinput change. This code does most of the heavy lifting for you, but its all built on event subscription from one input element to another.

    • Sebastiaan Draaisma

      Yeah, you need to use javascript and toggle a div visibility based on your selection. The div will than contain your attachment widget.