Using a Button instead of an Action Button to Submit a Form

In some case you want complete control over how the form gets submitted.  You can do this by invoking "submit" via a button (or any other object) instead of using the Action Buttons.  This provides you with freedom to place the buttons anywhere on the form.  (although you can place submit buttons where you want via CSS).

Here are the steps to doing this and an example app to learn from


Add this code to to the form onShowActionButtons event:

var actions = form.getStageActions();
for(var i=0; i<actions.length; i++)
{
  if(get(actions,i).getId() === 'S_Submit') // make sure the ID matches your Action
  {
    get(actions,i).setVisible(false);
  }
}

This will hide the Action buttons. The reason we do this versus simply setting the Action Buttons not to show on the page properties dialog box is because they need to exist for us to call them via JavaScript.  This way they become part of the app and are hidden from view.

Add this code to your Custom Button onClick event:

var actions = form.getStageActions();
for(var i=0; i<actions.length; i++)
{
  if(get(actions,i).getId() === 'S_Submit') // make sure the ID matches your Action
  {
    get(actions,i).activate();
    break;
  }
}


This code will get the Action and execute it.