To create separate functionality, you're best off creating a new destination file, a la, Save.php.
The button click should submit the form to that destination exactly like the Save button, but with a different action (let's call it Foo.php).
The button would look like:
Code:
<input type='submit' name='fooButton' class='button'
onclick="this.form.action.value='Foo';
this.form.module.value='{RETURN_MODULE}';
this.form.record.value='{RETURN_ID}';"
..etc.>
The Foo.php page should be based on something familiar. In most cases, I would recommend dissecting Save.php, but Emails' Save.php is rather complicated and messy.
The basic premise is:
1. take the values submitted via the form ($_REQUEST superglobal) and do some stuff with it.
PHP Code:
$name = myCustomFunctionThatReturnsAString($_REQUEST['name']);
$desc = myEmailBodyProcessor($_REQUEST['description']);
2. save the stuff and redirect to the DetailView page (typical flow).
PHP Code:
// instantiate new Email object
$email = new Email();
// popuplate necessary fields after processing
$email->name = $name; // processed above
$email->description = $desc; // also processed above
// save them
$email->save();
// redirect to the final destination page;
header("index.php?module=Emails&action=DetailView&id={$email->id}");
die();
HTH.
Bookmarks