Page 1 of 1

Custom submit button with copy functionality

Posted: Tue Jun 13, 2017 7:16 am
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.


Re: Custom submit button with copy functionality

Posted: Tue Jun 13, 2017 11:46 am
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.


Re: Custom submit button with copy functionality

Posted: Wed Jun 14, 2017 11:32 pm
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.


Re: Custom submit button with copy functionality

Posted: Fri Jun 16, 2017 10:32 am
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.


Re: Custom submit button with copy functionality

Posted: Fri Jun 16, 2017 12:11 pm
by sangnandar

Yes. Thanks.