The info in some of the older threads doesn’t seem to be working anymore, so I thought I’d post my solution to this.
I’m using the normal save button as ‘save draft’, and I have another button that ‘submits’ the form and its data. However as the user may click that without first saving the form, I needed the button to save the form data and then run some custom php. My solution:
2 buttons, one JS that the user clicks. Another PHP that is hidden.
The user clicks on the JS button which saves the form and then executes an AJAX call to button 2. Button 2 then executes PHP on the server.
Visible button:
Label: “Submit for Processing”
Type: Javascript
Code:
nm_atualiza(‘alterar’); //saves the form
sc_btn_submit(); // ajax call to the second hidden button. In my case that button is called ‘submit’.
Hidden button:
Name: submit //This is the name used when you first create the button. You can’t change it once the button is created.
Label: Doesn’t matter
Type: PHP
Code:
// Run your custom php here
sc_redir(‘main_menu’);