Login Retreive lost passwordRegister
Search

Manual  /  Functions  /  Database Functions  /  OnSaved

OnSaved
OnSaved (
string $callback
)

Arguments:

Name Description
$callback The name of the function which should be called when the form is correct and saved into the database.
It is also possible to use a method. In this case you should pass an array where the first item is the object and the second item the name of the method.

Description:

Set the function which has to be called when the form is saved. Your function will get 2 arguments from FormHandler:

1. The ID of the saved record.
2. An array of the data which is saved. The keys of this array represents the field names of the form.

You can also use a method which has to be called when the form is saved. You can do this like shown in example 2.

Example

<?php

// .... your form here..

// set the commit after save function
$form->onSaved("doRun");

// flush the form
$form->flush();

// the onsaved function
function doRun$id$data 
{
    echo 
"The record is saved with id: ".$id." <br />\n";
    echo 
"Data of the form: <pre>\n";
    
print_r$data );
    echo 
"</pre>\n";
}
?>


Example 2: Calling a method

<?php

// ......

// this is just a example object!
$obj = new YourClass();

// set the method which we should call when the form is saved
$form->onSaved(
  
// note: the & caracter is needed!
  
array( &$obj"methodName" )
);

// flush the form
$form->flush();

?>

Latest change: 05 March 10 / 08:56

Comments

powered by PHP-GLOBE   © 2004 - 2024 FormHandler. All rights reserved.   -   Open source license