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
BedrockMission!

Learn More

View all

Sign in to view all badges

Adaptive forms - visibility/access expressions and mandatory option

Avatar

Avatar
Validate 1
Level 3
daniel_henriqu1
Level 3

Likes

15 likes

Total Posts

56 posts

Correct Reply

10 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 3
daniel_henriqu1
Level 3

Likes

15 likes

Total Posts

56 posts

Correct Reply

10 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
daniel_henriqu1
Level 3

11-04-2016

Hi.

We've been using adaptive forms on AEM 6.1.

As an author, is it possible to turn a field into mandatory only when its visibility and access expressions (on the script tab) evaluate both to true?
Or should I always write a validation expression in order to do that, repeating the visibility and access expressions?

As a developer, how can I make this easier for our website authors?

Thanks!

Regards,

Daniel.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 1
Level 2
sixteenlabsinc
Level 2

Likes

7 likes

Total Posts

32 posts

Correct Reply

9 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Affirm 5
View profile

Avatar
Validate 1
Level 2
sixteenlabsinc
Level 2

Likes

7 likes

Total Posts

32 posts

Correct Reply

9 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Affirm 5
View profile
sixteenlabsinc
Level 2

30-11-2016

With an Adaptive Form, you need to wait until the Adaptive Form is ready, not the document DOM.

Try the following:

window.addEventListener("bridgeInitializeStart", function(evnt) { //this function will be called after adaptive form is initialized // get hold of the guideBridge object gb = evnt.detail.guideBridge; //wait for the completion of adaptive forms gb.connect(function (){ console.log(mainJSVersion); initializeForm(); }) });

Note that the initializeForm() function contains all of my function code. Also, I have a variable in the script called "mainJSVersion" that simply contains the date and time of my last edit. Client-side caching with client-libs can be painful, so with the version or date and time of my last edit displaying in the console, I get confirmation that I have the current version.

Answers (8)

Answers (8)

Avatar

Avatar
Validate 1
Level 2
Balu_M
Level 2

Likes

5 likes

Total Posts

36 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 2
Balu_M
Level 2

Likes

5 likes

Total Posts

36 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile
Balu_M
Level 2

07-12-2016

Hi Kautuk Sahni,

I tried to Mark it as answer but i could not find option, i have posted my question in existing thread.

Avatar

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,157 likes

Total Posts

6,247 posts

Correct Reply

1,144 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,157 likes

Total Posts

6,247 posts

Correct Reply

1,144 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile
kautuk_sahni
Community Manager

05-12-2016

Balu M wrote...

Thanks for your reply, its working now.

Can you please help me how to skip in-built validations and invoke custom validations when user submitted form.

We are using textbox component for email, i am trying to apply email format validations on this filed when user provided data. but when user submitted form these email validations not applying since validate() verifying only field is empty or not. 

I found validate(); but not sure how to override it.

 

 

 

Hi 

If your primary question is answered ans working for you. 

I would request you to please mark this question as answered and create a new post for followup question.

Thanks and Regards

Kautuk Sahni

Avatar

Avatar
Validate 1
Level 2
Balu_M
Level 2

Likes

5 likes

Total Posts

36 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 2
Balu_M
Level 2

Likes

5 likes

Total Posts

36 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile
Balu_M
Level 2

30-11-2016

Thanks for your reply, its working now.

Can you please help me how to skip in-built validations and invoke custom validations when user submitted form.

We are using textbox component for email, i am trying to apply email format validations on this filed when user provided data. but when user submitted form these email validations not applying since validate() verifying only field is empty or not. 

I found validate(); but not sure how to override it.

Avatar

Avatar
Boost 5
Employee
deepak_k_
Employee

Likes

5 likes

Total Posts

84 posts

Correct Reply

32 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Affirm 5
Affirm 3
View profile

Avatar
Boost 5
Employee
deepak_k_
Employee

Likes

5 likes

Total Posts

84 posts

Correct Reply

32 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Affirm 5
Affirm 3
View profile
deepak_k_
Employee

17-04-2016

With the AEM Forms 6.1FP1 (or later patches), the validations get auto disabled for hidden fields/panels. Please check that.

Avatar

Avatar
Validate 1
Level 3
daniel_henriqu1
Level 3

Likes

15 likes

Total Posts

56 posts

Correct Reply

10 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 3
daniel_henriqu1
Level 3

Likes

15 likes

Total Posts

56 posts

Correct Reply

10 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
daniel_henriqu1
Level 3

14-04-2016

It sounds very nice, Urs. Thanks!

Avatar

Avatar
Validate 1
Level 3
daniel_henriqu1
Level 3

Likes

15 likes

Total Posts

56 posts

Correct Reply

10 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 3
daniel_henriqu1
Level 3

Likes

15 likes

Total Posts

56 posts

Correct Reply

10 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
daniel_henriqu1
Level 3

14-04-2016

Thanks, Rishi!

Avatar

Avatar
Validate 1
Level 2
urs_h_
Level 2

Likes

5 likes

Total Posts

42 posts

Correct Reply

6 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Affirm 5
View profile

Avatar
Validate 1
Level 2
urs_h_
Level 2

Likes

5 likes

Total Posts

42 posts

Correct Reply

6 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Affirm 5
View profile
urs_h_
Level 2

14-04-2016

Hi Daniel

I've written a clientlib that

  • disables validation on widget and widgets within panels (even nested)
  • clears the value of invisbile widgets
var widgetClassesToIgnore = [ 'guideButton', 'guideInstanceManager', 'guidePanel', 'guideTextDraw', 'guideToolbar', 'rootPanelNode' ]; function resetWidget(widget) { if (widgetClassesToIgnore.indexOf(widget.className) == -1) { widget.value = null; } if(widget.items) { widget.items.forEach(function(child) { resetWidget(child); }); } } window.addEventListener("bridgeInitializeStart", function(event) { var gb = event.detail.guideBridge; gb.connect(function() { // first time initialization: all widgets that are not visible shall // not be validated gb.visit(function(widget) { widget.validationsDisabled = !widget.visible; }); // every time visibility changes let's check whether the widget // shall be validated or not gb.on('elementVisibleChanged', function(event, data) { var widget = gb.resolveNode(data.target.somExpression); if (data.newText) { widget.validationsDisabled = false; } else { resetWidget(widget); widget.validationsDisabled = true; } }); }); });

My assumption is that fields that become invisible are not important for the form anymore and I don't want to have them in the payload once the form is submitted. That's why I set their values to null.
Regards,
Urs

Avatar

Avatar
Boost 1
Level 2
rishim22446870
Level 2

Likes

2 likes

Total Posts

32 posts

Correct Reply

12 solutions
Top badges earned
Boost 1
Affirm 5
Affirm 3
Affirm 10
Affirm 1
View profile

Avatar
Boost 1
Level 2
rishim22446870
Level 2

Likes

2 likes

Total Posts

32 posts

Correct Reply

12 solutions
Top badges earned
Boost 1
Affirm 5
Affirm 3
Affirm 10
Affirm 1
View profile
rishim22446870
Level 2

13-04-2016

Hi Daniel,

The functionality to "set" a mandatory property for a field was introduced in 6.1 Feature Pack 1. For the given use-case, you can follow the steps mentioned below:

a) Say, we are controlling visibility of a field Y based on a field's(say X) value.

b) On "value commit" script of X, you can write the following script,

if(this.value === "4"){ Y.visible = true; Y.mandatory = true; } else { Y.visible = false; }

A similar approach could be followed for "access" too.

Hope this solve's your use-case.

Thanks,

Rishi