NetTalk Central

Author Topic: Two save buttons on the form  (Read 6809 times)

alex.kolaric

  • Full Member
  • ***
  • Posts: 151
  • Do it or do not, there is no try
    • View Profile
    • Email
Two save buttons on the form
« on: November 09, 2010, 08:26:22 AM »
Hi,

Is it possible to have 2 save buttons on the form, for example Save and Approve where both of them would save the changes to the record and if you click Approve some additional fields in the record would be set?

thanks,
Alex

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Two save buttons on the form
« Reply #1 on: November 09, 2010, 10:58:49 PM »
To answer your first question, yes you can have 2 save buttons on a form. You can add a Save button simply by adding a button field to the form, and setting it to be a "Save" button.

But what you're wanting methinks is not a save button. You want an approve button, which does a save, and then follows it up with some more code. You'd need to experiment a bit to see the best way of doing this - perhaps when you add another save button you can tell one button from the other? I'm not sure, this isn't something I've tried.

Of course an alternative is to add a checkbox to the form, "approved", and if this is on then handle the code on save differently.

cheers
Bruce

alex.kolaric

  • Full Member
  • ***
  • Posts: 151
  • Do it or do not, there is no try
    • View Profile
    • Email
Re: Two save buttons on the form
« Reply #2 on: November 10, 2010, 06:00:38 AM »
Hi Bruce,

thanks for your answer. I know that there is an easy way to add save button on the form but I'm not sure if it is possible to determine which one was pressed when validating. I will give it a try and if you find out something in the meantime don't be a stranger  :)

Regards,
Alex

Ubaidullah

  • Full Member
  • ***
  • Posts: 125
    • View Profile
Re: Two save buttons on the form
« Reply #3 on: March 27, 2011, 09:58:41 AM »
I will give it a try and if you find out something in the meantime don't be a stranger  :)

Regards,
Alex

Hi Alex,

Did you find a way to do this? I am in the same position and need two save buttons on the form with one of them setting a flag before saving.

Regards,
Ubaidullah Nubar.


Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Two save buttons on the form
« Reply #4 on: March 27, 2011, 11:57:10 PM »
For build 5.21 I have added a value
_buttontext_
which is set when the saved button is pressed.

So in your "save handling code" you can test the value of
p_web.GetValue('_buttontext_')
to see which button was pressed.

cheers
Bruce

alex.kolaric

  • Full Member
  • ***
  • Posts: 151
  • Do it or do not, there is no try
    • View Profile
    • Email
Re: Two save buttons on the form
« Reply #5 on: March 28, 2011, 01:04:37 AM »
Oooh this is nice, so nice. Two candies within one update  :D

Regards,
Alex

Ubaidullah

  • Full Member
  • ***
  • Posts: 125
    • View Profile
Re: Two save buttons on the form
« Reply #6 on: March 28, 2011, 11:49:51 PM »
For build 5.21 I have added a value
_buttontext_
which is set when the saved button is pressed.

Thanks, Bruce.

Now, is there a way to add buttons on the same row as the standard Save button?

Regards,
Ubaidullah Nubar.

Ubaidullah

  • Full Member
  • ***
  • Posts: 125
    • View Profile
Re: Two save buttons on the form
« Reply #7 on: April 19, 2011, 09:20:00 AM »
For build 5.21 I have added a value
_buttontext_
which is set when the saved button is pressed.

So in your "save handling code" you can test the value of
p_web.GetValue('_buttontext_')
to see which button was pressed.

Thanks for this Bruce.

I must be missing something simple. How do I set buttontext in the first place? When I set a button type to 'save', the 'text' prompt gets disabled.


Regards,
Ubaidullah Nubar.

Ubaidullah

  • Full Member
  • ***
  • Posts: 125
    • View Profile
Re: Two save buttons on the form
« Reply #8 on: April 19, 2011, 10:12:38 AM »
I must be missing something simple. How do I set buttontext in the first place? When I set a button type to 'save', the 'text' prompt gets disabled.

I managed to do this by setting the value of  p_web.site.SaveButton.textvalue in the value:: routine for the button. I saved the existing value at the top of the routine and restored it in the end so the main Save button does not get affected.

But, there must be an easier/better way.

Regards,
Ubaidullah Nubar.