Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Disabling fields in a repeatable subform.

Avatar

Level 2

I would like to know if it is possible to disable all fields in a subform when a new instance is added?

4 Replies

Avatar

Level 7

Are you referring to the old subform?

e.g., I'm filling out a job application and adding my previous experience. I enter the information for job 1, then click a button "add another." The Job1 information becomes read-only.

Adding this to the click event for your button that creates a new instance (or whatever applicable event) will do that.

var q = sfRepeat.instanceManager.count - 1;

sfRepeat.instanceManager.addInstance();

xfa.resolveNode("sfRepeat["+q+"].tfTest").access = "readOnly";

Avatar

Level 2

Yes that is exactly what I would like to do. Am I able to appy that code directly to my form? The subform I would like to repeat has several fields, primarily text.

Avatar

Level 7

Yes, just delete the .tfTest in the last line.

var q = sfRepeat.instanceManager.count - 1;

sfRepeat.instanceManager.addInstance();

xfa.resolveNode("sfRepeat["+q+"]").access = "readOnly";

Avatar

Level 2

That worked perfectly! Thank you so much for your help!