# FormInDialog onHide

**URL:** <https://forum.servoy.com/t/formindialog-onhide/2457>\
**Category:** Classic Servoy\
**Created:** [August 12, 2004, 4:20pm UTC](https://forum.servoy.com/t/formindialog-onhide/2457 "2004-08-12T16:20:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Morley](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@Morley](https://forum.servoy.com/u/Morley)\
**Post date:** [August 12, 2004, 4:20pm UTC](https://forum.servoy.com/t/formindialog-onhide/2457/1 "2004-08-12T16:20:41Z")

</div>

I have a FormInDialogue with a single “Confirm” button which I’d like to force the user to deal with. I don’t want them clicking the close button.

I’ve created an onHide method.

```auto
plugins.dialogs.showErrorDialog('Error','<html>Please complete the information for the personnel records
and use the Confirm button to close this dialogue.')
return false;

```

This does the trick. However it also activates when the user clicks the Confirm button. I’ve tried adding

```auto
return true;
forms.securityAdmin.controller.show();

```

as the final steps of the “Confirm” method. Doesn’t work.

The problem might be solved if I gave the “onHide” method a conditional that the Confirm button wasn’t being activated. Any ideas?

---

<div class="post-metadata">

**Author:** ![Harry\_Catharell](https://avatars.discourse-cdn.com/v4/letter/h/e19adc/32.png) [@Harry\_Catharell](https://forum.servoy.com/u/Harry_Catharell)\
**Post date:** [August 12, 2004, 4:37pm UTC](https://forum.servoy.com/t/formindialog-onhide/2457/2 "2004-08-12T16:37:20Z")

</div>

Hi Morley,

Create a global variable called ‘gFlag’ which is type number

Modify your ‘Confirm’ method as follows :

```auto
globals.gFlag = 1
//the rest of your confirm method as is

```

Modify your onHide method as follows :

```auto
if ( globals.gFlag != 1 )
{
	plugins.dialogs.showErrorDialog('Error','<html>Please complete the information for the personnel records
and use the Confirm button to close this dialogue.') 
	return false;
}
else
{
globals.gFlag = null
}

```

When the user clicks the confirm button then the flag will be set to ‘1’ and the onHide method will pass over the error dialogue and then reset itself to null  
If the user clicks on the close box then the flag is null and the onHide method error dialogue will trigger

Hope this helps

Harry

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [August 12, 2004, 5:29pm UTC](https://forum.servoy.com/t/formindialog-onhide/2457/3 "2004-08-12T17:29:18Z")

</div>

or - my favourite: use a transaction.

---

<div class="post-metadata">

**Author:** ![Morley](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@Morley](https://forum.servoy.com/u/Morley)\
**Post date:** [August 12, 2004, 6:06pm UTC](https://forum.servoy.com/t/formindialog-onhide/2457/4 "2004-08-12T18:06:44Z")

</div>

> patrick:  
> or - my favourite: use a transaction.

?? Please explain, that was too terse for this new user.

In the meantime, Harry’s approach works.
