Expand my Community achievements bar.

SOLVED

Hidden field prepopulated from DB.

Avatar

Former Community Member

 

When the form is rendered , I have a text field that is Visible but wrapped in Hidden Subform. You cannot see it unitl you click of the button; Subform is Visible and you can enter data in the field. Works fine.

Can someone explain what happens when this field is prepopulated from database. The Subform that hold field is hidden. Is it going to show data when the form is rendered or you have to click on the button to see it?

Thank you,

1 Accepted Solution

Avatar

Correct answer by
Level 4

Hi 1996, sorry for the late reply.

Alright, like I said, visibility is never affected by an import. If you want to show information in a field, the field has to be visible, and all of the field's parent subforms need to be visible as well. If any of the subforms that the field is nested within are hidden, the field will remain hidden, regardless of whether or not you import data into it.

This behavior is different from binding data to a repeatable subform with an initial count of 0. In this case, so long as the import puts some data into the repeatable subform, it will automatically add enough 'rows' to show everything. Again, if the visibility is set to 'hidden' it doesn't matter if it adds enough rows to include all of the imported data, it will still be hidden. The repeatable subform, and every subform that it is nested within needs to be visible, or nothing will show up, regardless of the import.

In short, hidden subforms/fields will stay hidden, until you programatically tell them not to be. You can have a repeatable subform with an initial count of 0, and it will dynamically add rows to support the imported data.

In your situation, I would have to see your form to see why binding the data didn't make work.

I'm at work right now, but during my lunch break, I'll send you a sample form that shows how I would handle your described situation. You should receive it in around 4 hours.

- Scott

View solution in original post

8 Replies

Avatar

Level 4

Hi there,

When you populate the form from the database, visibility is never affected. Anything that is visible stays visible... anything hidden stays hidden.

What you can do is use a little formcalc to check if the field has a value, and if so, show the parent subform. This solution assumes that you don't have a hide button. If you do, you should change the hide/show buttons to a single checkbox, then check the checkbox 'srawvalue to see what state of visibility the subform should use.

code (put in the field in the hidden subform... under it's layout:ready event):

 

if (HasValue($)) then

     $.parent.presence = "visible"

endif

Avatar

Former Community Member

Thank you so very much for your suggestion. I've added the code and sent it for testing. Will update when I hear back results.

Avatar

Former Community Member

Hi past-tense,

Your suggestion worked, thank you so much.

What would be solution in case where you have Hidden subform1 that holds another 3 suboforms ( subA, subB and subC all visible ) with the number of fields. My client does not want to see subform1 unless the button + is clicked but wants to see it if the form is pre-populated from the databse. Do I put the code below on each fields of subA, subB and subC in order to accomplish that? I would love to know that before I send it to developer. Is the only solution to keep subform1 visible?

Thank you!

  

if (HasValue($)) then

     $.parent.presence = "visible"

endif

Avatar

Former Community Member

Hello,

I have made subform1 visible but set Inital Count = 0. They still cannot see data. Any suggestion?

I have a question around this statment "When you populate the form from the database, visibility is never affected. Anything that is visible stays visible... anything hidden stays hidden."

But what is with the data...is data inside the hidden subforms or fields? Can you push the data in hidden subforms (or subforms with Initial Count set to 0) or they have to be visible to accept data.

Avatar

Correct answer by
Level 4

Hi 1996, sorry for the late reply.

Alright, like I said, visibility is never affected by an import. If you want to show information in a field, the field has to be visible, and all of the field's parent subforms need to be visible as well. If any of the subforms that the field is nested within are hidden, the field will remain hidden, regardless of whether or not you import data into it.

This behavior is different from binding data to a repeatable subform with an initial count of 0. In this case, so long as the import puts some data into the repeatable subform, it will automatically add enough 'rows' to show everything. Again, if the visibility is set to 'hidden' it doesn't matter if it adds enough rows to include all of the imported data, it will still be hidden. The repeatable subform, and every subform that it is nested within needs to be visible, or nothing will show up, regardless of the import.

In short, hidden subforms/fields will stay hidden, until you programatically tell them not to be. You can have a repeatable subform with an initial count of 0, and it will dynamically add rows to support the imported data.

In your situation, I would have to see your form to see why binding the data didn't make work.

I'm at work right now, but during my lunch break, I'll send you a sample form that shows how I would handle your described situation. You should receive it in around 4 hours.

- Scott

Avatar

Former Community Member

That make sense.

Very kind of you, thank you so much.

Avatar

Level 4

Hi again 1996,

Here is a sample of how I would design a repeatable subfrom that:

- Starts with no records showing (Initial Count = 0) until either data is imported or the user clicks a button.

- Dynamically shows/hides a friendly message to let the user know if there are no records.

- Micromanages the tab order of the fields by checking whether the fields were exited by using a tab key. If so, it determines the most appropriate field to go to.

          (I did this because, in my experience, the default tab order does not function properly for repeatable subforms.)

- Hides the buttons from being printed (I don't like form printouts to have the buttons showing).

- Shows/Hides the various buttons on-screen, depending on whether or not the user should be able to use the button. (If the user shouldn't be able to click a button, I don't think it should be shown).

- Allows the user to add/remove/reposition the 'rows' of the repeatable subform.

All of this functionality can be found in the click, layout:ready, exit and initialize events, where appropriate.

The linked file is a zipped folder (sampleForm.zip) that contains the pdf, as well as a sample XML file to be imported.

That link will expire in about a month. Just a heads up to anyone reading this in the future.

Let me know if you have any questions about how this form is set up.

- Scott

Avatar

Former Community Member

I really appreciate your help. That worked perfectly.