Back to FormController class

Method allowSave

protected bool
allowSave
(mixed $data, mixed $key = 'id')
Method to check if you can save a new or existing record.
Parameters
  • array $data An array of input data.
  • string $key The name of the key for the primary key.
Returns
  • bool
Since
  • 1.6

Method allowSave - Source code

/**
 * Method to check if you can save a new or existing record.
 *
 * Extended classes can override this if necessary.
 *
 * @param   array   $data  An array of input data.
 * @param   string  $key   The name of the key for the primary key.
 *
 * @return  boolean
 *
 * @since   1.6
 */
protected function allowSave($data, $key = 'id')
{
    $recordId = $data[$key] ?? '0';
    if ($recordId) {
        return $this->allowEdit($data, $key);
    } else {
        return $this->allowAdd($data);
    }
}