Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

Setting hidden fields to null


Level 10

I guess this is more of a best practices kind of question.

A filler has entered a bunch of data in a subform. They then change an earlier option which causes that subform to disappear and a different one to appear.
As well as setting mandatory fields off and on, what are people doing with the previously entered data? Leave the data alone or blank the data? Are there any problems with data in hidden subforms when it comes to exporting XML or anything like that?
The downside I can see to blanking the data is that if the filler changes their mind again they would have to re-enter the data.
1 Reply


Level 10

Hi Jono,

I would normally null the field when it is hidden.

Depending on how the data is being submitted, you could go for something like this in the preSave or preSubmit event of the field:

if (this.parent.presence == "hidden")


     this.rawValue = null


Structure would depend on what you are hiding and how many objects you have. Also a specific resetData(), targeting particular objects could be used instead of the .rawValue=null.

Good luck,


Message was formatted and edited by: Niall O'Donovan