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.
SOLVED

Subform Fields Are Read Only

Avatar

Former Community Member

Hello, I'm not sure if this is a bug or a setting.  But I have a working form with subforms, if I copy a subform which already has controls on it and is functioning correctly and paste it (or duplicate it for that matter), when I preview it, those pasted controls are all read only and not able to type into them.

Anyone have any ideas why that would happen?

Thanks

Joe

Problem.jpg

*update*  I just uploaded the above image of the subforms, the top one correct, the bottom one after copy and pasting the top one and renaming it, it has now become read-only

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

Ah..I just caught this error and found your script on the sub-form calculate.

if (GenericNetworkInformation.ddlNumberofServers >= "1") then

sfServer1.presence = "visible" else

sfServer1.presence = "hidden"

endif

The attached form is updated.

Steve

View solution in original post

8 Replies

Avatar

Former Community Member

Joe,

If you can you post a form extract with the two subforms, I can take look.

Steve

Avatar

Former Community Member

Here's a copy of the form with the two subforms.  Thanks for your help.

Joe

Avatar

Former Community Member

Joe,

I am not sure, but perhaps some script got removed when you cut-and-paste your extract because I did not see any script on the drop-down object or any data binding to the drop-down value. More importantly, I am not sure why the drop-down worked at all.

I removed the drop-down and added a button to call the InstanceManager to generate new instances of sub-form 'sfServer1'. The new sub-forms behave correctly.

Steve

Avatar

Correct answer by
Former Community Member

Ah..I just caught this error and found your script on the sub-form calculate.

if (GenericNetworkInformation.ddlNumberofServers >= "1") then

sfServer1.presence = "visible" else

sfServer1.presence = "hidden"

endif

The attached form is updated.

Steve

Avatar

Former Community Member

Hey Steve,

That worked perfect.  I didnt' realize you could do add a second instance of subform using that command.

Is there anyway to get that to work via a drop down box instead of a button?  Thanks

Joe

Avatar

Former Community Member

Hi Joe,

No you cannot. The addInstance method does not take an integer argument. The method as commonly coded below can be misleading. The argument is a boolean 'true' and not an indication of the number of instances to add.

form1.Servers.Servers.sfServer1.instanceManager.addInstance(1);

Steve

Avatar

Former Community Member

Hey Steve,

Thanks a lot for the information.  It's nice to have a resource like you to help people like me.

Last question about this topic.  Is there a way then to count the amount of instances of a subform?

Thanks

Joe

Avatar

Former Community Member

You're welcome Joe. There are a lot of people who contribute to the forum to make it a useful resource.

I want to clarify my response about adding subforms using a drop-down. There is an instanceManager method called 'setInstances' that creates a specific number of subform instances. You could use a drop-down in the following manner.

// form1.Servers.GenericNetworkInformation.addServerDropDown::exit - (JavaScript, client)

form1.Servers.server.instanceManager.setInstances(this.rawValue);

Regarding getting the subform count, there is an instanceManger property called 'count'.

I added a drop-down and a button to get the count in the attached form.

Steve

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----