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.

how to stop a form from being editable

Avatar

Level 1

Hi,

we created a form for a client that their auditors are simply downloading, completing and submitting back to the client via form upload. the fowm contains dropdon fields and text areas. the client then needs to send the form to a third party. The form needs to be locked so no amendments can be made. The client has tried combining the form with an additional pdf, but the text areas then do not show overflow, the "+" appears in bottom right corner but can not be clicked to expand. Can someone help/advise the solution please...doing our heads in now....

5 Replies

Avatar

Level 10

Hi,

There is a LoclAllFields solution, but when the fields are readOnly you will not be able to access data below the bounds of the field (not visible).

I have a form on our website that was developed a few years ago: http://www.assurehsc.ie/files/2007-08-31_Designer_Risk_Assessments_Example-1.pdf

It is intended as a sample/information/instruction tool. Because it is up on the web I wanted visitors to explore the look and feel, but not to download an use at will. So the fields are set to 'open', but the initial value is read on the enter event, stored and then on exit the original value is restored.

Parallels Desktop1.png

This is a solution from the forum (Stefan, I think). If you insert a script object called 'Utils', with the following javascript:

var sOriginalValue = "";

Then in the fields enter event:

Utils.sOriginalValue = this.rawValue; // store original value into script object variable

And in the fields exit event:

this.rawValue = Utils.sOriginalValue; // restore original value from script object variable

Utils.sOriginalValue = ""; // reset saved value

This solution runs all the time. In your case you would need a flag to track if the script it to run or not, eg turning on and off the feature.

Hope that helps,

Niall

Avatar

Level 1

Thanks for taking the time to post your advice - do you have to add a variable per field, then exit and enter events per field also?

Avatar

Level 10

Hi,

You could go for a global variable (File > Form Properties > Variables tab), called 'locked' and set it to 0 initially (eg not locked).

Also you would need to make sure that the defaults are set to 'Automatically save script changes' in the File > Form Properties > Defaults tab.

You could leave the script object as it is AND you could leave the enter event script as is.

The only thing to change would be to wrap the exit event script in an if statement to check the status of the global variable.

if(locked.value == 1) // form is locked

{

     this.rawValue = Utils.sOriginalValue; // restore original value from script object variable

     Utils.sOriginalValue = ""; // reset saved value

}

Your locking script would then change the global variable to 1, which will allow the protection of the field.

A couple of things to note:

  • In the past I have had trouble getting global variables to stick with the amended value. In other words it may revert to 0 each time it is opened. If this is the case just run with a hidden numeric field.
  • While accessing the value of objects on the form you use '.rawValue', when accessing or setting the value of global variables you use '.value'.

Hope that helps,

Niall

PS, Yes, in our current setup there are enter and exit scripts in each of the fields.

Avatar

Level 1

fantastic...you help is very much appreciated!