Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

image drag and drop required field should apply only when variation selected

charant2010807
Level 2
Level 2

Hi 

I have a component with two variations which have Drag and drop image field in both the variations, Image field in both the variations are required field.

I have a added required.js file to my component, the problem is when I select one variation and filled the mandatory fields and try to submit it is not submitting and it is highlighting the image field in other variation.

I want image field to be highlighted only when I select the particular variation and if it is not authored. 

I have attached the validation code which I used in my component, Please advice.

8 Replies
edubey
Level 10
Level 10

I don't think AEM has any properties which takes care of it.

All I think of is you need write your own validation. 

1. Remove all required attribute by default

2. When user select a particular variation, add required attribute only to the field of selected variation.

3. Make sure you change this when user toggle variation.

Thanks

charant2010807
Level 2
Level 2

Hi,

Can you please, provide me the sample validation script for variation.

smacdonald2008
Level 10
Level 10

Can you show a screen shot of your component and component dialog so it clearer what exactly you want to do. I am not clear on what you mean. 

charant2010807
Level 2
Level 2

Hi 

I have component in which I have two variations graphical and text, In In both variations image is required field 

I just want image to be drag and dropped I don't want the upload functionality,  I Have added required.js file to my component

After adding required.js once I authored the graphical layout and try to submit it is not allowing me to submit, it is making image field in text variation as required.

the required.js which I added it is making all the image fields in component as required, I wanted it to be highlighted only when I select the variation.

I have attached the js code and screenshot of my component structure

charant2010807
Level 2
Level 2

Hi Edubey I am trying to write custom validation code for this but it is so complex and I am not able to get it work as expected, please help.

Thanks in advance.

smacdonald2008
Level 10
Level 10

Are you working in Classic UI or Touch UI?