# get the parent form

**URL:** <https://forum.servoy.com/t/get-the-parent-form/10385>\
**Category:** Classic Servoy\
**Created:** [March 9, 2009, 8:47am UTC](https://forum.servoy.com/t/get-the-parent-form/10385 "2009-03-09T08:47:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [March 9, 2009, 8:47am UTC](https://forum.servoy.com/t/get-the-parent-form/10385/1 "2009-03-09T08:47:38Z")

</div>

Hi there,

I need some code where I can detect on which form, my form is placed (in a tabpanel)

for example:

I have form B, which is placed in a tabpanel on form A.  
I want to detect on form B that I’m placed on form A (kind of getParentForm ![;-)]( "Wink") )

I can’t use currentcontroller, because in my case, form A ‘can’ be placed in a tabpanel on form C.

Anyone??

---

<div class="post-metadata">

**Author:** ![Joas](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/joas/32/5095_2.png) [@Joas](https://forum.servoy.com/u/Joas)\
**Post date:** [March 10, 2009, 8:16am UTC](https://forum.servoy.com/t/get-the-parent-form/10385/2 "2009-03-10T08:16:22Z")

</div>

I don’t think there’s a straight forward way to do this. Looping recursively through all the tabs from the currencontroller form doesn’t work if your form can be on multiple tabs, as you said.

So I think the only option is to “keep track” yourself while your user is navigating through your application. For example: Have a global onShow-method add the formname to a global array for all (levels of) forms.

---

<div class="post-metadata">

**Author:** ![pbakker](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@pbakker](https://forum.servoy.com/u/pbakker)\
**Post date:** [March 10, 2009, 11:15am UTC](https://forum.servoy.com/t/get-the-parent-form/10385/3 "2009-03-10T11:15:42Z")

</div>

As a form can only be visible once, you could loop through the entire tree of visible forms.

For now that is the only option.

In the next major version of Servoy, we’ll introduce a function on the form object to get it’s parent. This will off course only work for visible forms.

Paul

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [March 10, 2009, 11:37am UTC](https://forum.servoy.com/t/get-the-parent-form/10385/4 "2009-03-10T11:37:23Z")

</div>

> pbakker:  
> As a form can only be visible once, you could loop through the entire tree of visible forms.
> 
> For now that is the only option.  
> Paul

Do you have some sample-code how to loop through a tree, of visible forms??

---

<div class="post-metadata">

**Author:** ![pbakker](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@pbakker](https://forum.servoy.com/u/pbakker)\
**Post date:** [March 10, 2009, 12:56pm UTC](https://forum.servoy.com/t/get-the-parent-form/10385/5 "2009-03-10T12:56:34Z")

</div>

1- Start at the currentcontroller  
2- Loop through the elements on the form to find all tabpanels, or use the solutionModel (\>=4.1) to get all the tabpanels  
3- for each tabpanel:  
4- get the form in the active tab and do step 2 again

Paul

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [March 10, 2009, 1:12pm UTC](https://forum.servoy.com/t/get-the-parent-form/10385/6 "2009-03-10T13:12:10Z")

</div>

ah thanks,

will try that
