These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

removed subforms (using removeinstance) re-appear upon email submit

amandakempf
Registered: Mar 4 2010
Posts: 7
Answered

I have a form to create generic documents (like product specifications, assembly procedures, etc.) that essentially allows a user to add images or text in any order to fit his needs for that particular document.

The user adds content as needed, which by default adds both a subform with both an image field subform and a text field subform and the user can choose to delete either (or both) and/or add more content.

Everything works fine, but when the completed form is submitted (whether it be xml or pdf) all the deleted subforms reappear in the received document. Is there something small that I'm missing here or is just not possible to delete subforms at the host and have them stay gone through the form submission process? Thanks so much for any help/advice!

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
There are two mechanisms that can automatically create subforms. First of course is data. When you load a Dynamic LiveCycle form Acrobat merges the Template model and the Data model to create the runtime form model. It automatically creates repeated subforms to match the amount of data loaded.

In Acrobat 9 you also have the option of having Acrobat automatically restore the visual state of a dynamic form. This is on the default tab in the document properties dialog.

Originally in LiveCycle only the data was saved with the form. If there were graphical changes made on the form, like showing or hiding a field, these were lost. You had to write specical code to restore the visual state of the form based on the saved data. This is actually a core concept behind the LiveCycle model, i.e., data drives the configuration of the form. If there's no automatic, or built-in, connection between the data and the visual state of the from you have to have special code that makes this connection.

Unfortuantely a lot of people didn't get this and so Adobe added the feature to Automatically save and restore the visible state of the form along with the data.

Now, in your case I suspect you don't have this option checked, or you are using an older version. Without anthing else driving it Acrobat is simply displaying the original state of the form, as defined in the template model. In the case where there data only is being submitted the form may not restore correctly even with this option checked because, well, how would it know? The visual state data would have to be included in the data, which is might if the submitted data is XMP, but no other format could provide this info.

You would be better off redesigning your form with two changes. First, don't destroy the subforms, Just set the presence to hidden. Second, start off with the subforms hidden and use code on a checkbox to unhide them. In fact, include an Initialize event for the subform that shows or hides itself based on the state of the check box. This will solve your problem.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

amandakempf
Registered: Mar 4 2010
Posts: 7
Thanks so much for your thoughtful response.

My very first attempt WAS to simply hide/show the subforms, but I found that hiding them still kept an empty space where they had been. This resulted in obtrusive gaps in the submitted documents. I tried setting the subforms' dims to zero at the same time I hid them, but it didn't seem to work...

I should also mention that I just started working w/ LC and have learned a LOT, but it has been in a very jumbled and haphazard way!

I'll go back to the presence state and see if I can work it out that way...thanks again!
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Setting a subform presence to "hidden" removes it from the layout. If the containing subform is Flowed the empty space will dissappear.

Watch this eseminar:
https://admin.adobe.acrobat.com/_a200985228/p87746471/

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

amandakempf
Registered: Mar 4 2010
Posts: 7
Thanks--you're absolutely right (I must have been using "invisible" or something...) Sometimes the best thing after embarking on a long and twisted path is starting over again at the beginning! I simply added buttons to "Add Text" or "Add Image" which add a new instance of the subform, making either the text or image field visible accordingly.

Now I just need to troubleshoot why my user can't submit the form, but that's another thread... Many thanks again!
amandakempf
Registered: Mar 4 2010
Posts: 7
Apparently, the only way a typical user can submit my LC form is if I configure the button to send XML or XDP (unless they purchase LC Reader Extensions ES2, which is not at all possible.)

However, when I do configure to send as XML/XDP (after making the changes I mentioned above) when I merge the data with the orginal form, all the subforms all revert back to their original "hidden" states and I have no way of knowing which fields to show (i.e. which hidden fields have data).

I do seem to have the automatic state restore option checked, fwiw.

Perhaps I'm misunderstanding something here, but I now seem to be in a worse situation (missing all data instead of having a few extra empty subforms). Sorry if I'm slow, but I look forward to any help you can give!
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You can submit the form as PDF if you enable the form with Reader Save Rights. You'll find this option on the Acrobat Pro "Advanced" menu.

The idea with reloading data into the original form is that the data contains everything needed to rebuild the form. Now, there are two parts to this. There are those things that Acrobat takes care of automatically, and those things that need to be handled by custom code. You're form is designed in a way that requires custom code, i.e., setting the visibility of certain subforms.

So here's the best way to go about setting up your custom code. If you have check boxes that make the subforms visible, then place the code for doing this into an event that is triggered by a value change so that the code is triggered in both situations, when the uer clicks on the check box, and when the data is imported into the form. Typically form designers will place code into the MouseUp event for a checkbox. Bad Idea, This code is only triggered when the user clicks on the button. Use the Change or Validate events.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script