Custom submit button with copy functionality

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
sangnandar
User
Posts: 980

Custom submit button with copy functionality

Post by sangnandar »

My case, on Add page:
I need a custom button after Submit button, namely "Submit and Copy".
This button should do:

  • Submit the current form
  • Copy the current form value to new form // something like this with return pages after add: "<MyTable>add.php?id=" . urlencode($this->id->CurrentValue)

I have conditions on:

  1. Row_Inserted // do something on DB
  2. Row_Rendered // if (CurrentPageID() == "add") {discard copied value on some fields}
  3. Startup Script // Set values="" for some dropdown fields

I currently set return pages after add on Submit button to Copy url above. But then user had to cancel the last input, it's not cool.
I thought of JS+Ajax, but then I need to rewrite Row_Inserted conditions twice, one on server (for Submit button) and the other on client (for Submit and Copy button). It's not cool either.
Any pointer will be much appreciated.

Thanks.


mobhar
User
Posts: 11721

Post by mobhar »

What did you mean by "But then user had to cancel the last input" ? Please explain it in more detail for more discussion.


sangnandar
User
Posts: 980

Post by sangnandar »

I put this code on return pages after add: "<MyTable>add.php?id=" . urlencode($this->id->CurrentValue)
This code will copy the last inputted form to a new form.

So, when user click on Submit, he will be redirected to <MyTable>add.php , on and on.
When he finished all the input, on the last input he surely has to click Cancel to get back to List Page.

My plan is to create another button, namely "Submit and Copy".
This Submit and Copy will return to this: "<MyTable>add.php?id=" . urlencode($this->id->CurrentValue)
While Submit (only) will return to List Page.


arbei
User
Posts: 9382

Post by arbei »

You can try to add 1 more parameter when you submit in order to identify you want to redirect to list page or add page.

e.g.
$("#btnAction").on("click", function(e){
$("<input type='hidden' name='<new field>'>").val("<new value>").appendTo($("#f<table>edit"));
});

Then in Page_Redirecting Server Event, change the URL based on the parameter.


sangnandar
User
Posts: 980

Post by sangnandar »

Yes. Thanks.


Post Reply