public function onBeforeSaveEmployeeSettings(mixed &$data, JModel $model) : bool

Fires before saving the employee configuration.


Description

This hook is triggered before updating the settings of an employee from the Employees Area in the front-end. It can be used to bind the data that are going to be saved within the database.

TIP: in case of failure while saving the record, it is possible to throw an exception to abort the saving process and return a readable error message. The same can be accomplished by registering an error to the model and returning false.

// throw an exception
throw new Exception('Missing required field', 404);
// or register the error
$model->setError('Missing required field');
return false;

Parameters

&$data

(array|object)  Either an array or an object specifying the settings to bind.

$model

(JModel)  The model instance that handles the saving process.

Return Value

Boolean. Use false to abort the saving process.


Example

/**
 * Trigger hook to allow the plugins to bind the object that
 * is going to be saved.
 *
 * @param   mixed    &$data  The array/object to bind.
 * @param   JModel   $model  The model instance.
 *
 * @return  boolean  False to abort the saving process.
 */
public function onBeforeSaveEmployeeSettings($data, $model)
{
    /**
     * @todo it is possible to inject into $data further settings to save
     */

    return true;
}

Changelog

VersionDescription
1.7.0 Added $model arguments.
Accepted return value to abort the saving process.
1.6.6 Introduced.
Last Update: 2021-10-08 09:31
Helpful?