I add this to test snapshot in my model
public function afterCreate() {
$changedFields = $this->getChangedFields();
if (count($changedFields)) {
foreach ($changedFields as $field) {
$auditar = new Auditoria();
$auditar->AUD_MODELNAME = $field;
$auditar->AUD_IPADRESS = $request->getClientAddress();
$auditar->AUD_OLDVALUE = $originalData[$field];
$auditar->save();
if ($auditar->save() == false) {
foreach ($auditar->getMessages() as $message) {
echo $message, "\n";
}
}
}
}
}
I add this line to my function initialize
public function initialize() {
$this->setSchema("SPOLS");
$this->hasMany('CONT_CODIGO', 'SPMREFERENCIA', 'CONT_CODIGO', array('alias' => 'SPMREFERENCIA'));
$this->hasMany('CONT_CODIGO', 'SPTDETALLE', 'CONT_CODIGO', array('alias' => 'SPTDETALLE'));
$this->hasMany('CONT_CODIGO', 'SPTENCABEZADO', 'CONT_CODIGO', array('alias' => 'SPTENCABEZADO'));
$this->keepSnapshots(true);
}
but when saving me the following message
The record doesn't have a valid data snapshot
Could it be because some fields left empty?