CodeIgniter Forums
Missing data in $beforeUpdate callback function - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10)
+--- Thread: Missing data in $beforeUpdate callback function (/showthread.php?tid=87514)



Missing data in $beforeUpdate callback function - JoosepK - 04-27-2023

Hello! 
I try to create a
Code:
$beforeUpdate
 callback function to change date format for database:
Code:
protected $beforeUpdate = ['changeDateFormat'];

And when i try to check the incoming data, then i see that many fields are missing:
Code:
public function changeDateFormat(array $data)
{
        dd($data['data']);
}
It has only three fields: [id, fk_loan_id, updated_at], but it should have many more fields, like: base_data, loan_balance etc. 
Why can't i see all the values and how can i fix it?

Thank you for any help!


RE: Missing data in $beforeUpdate callback function - iRedds - 04-27-2023

All fields must be specified in the $allowedFields class property. And also if they are changed.


RE: Missing data in $beforeUpdate callback function - JoosepK - 04-27-2023

(04-27-2023, 11:06 AM)iRedds Wrote: All fields must be specified in the $allowedFields class property. And also if they are changed.

I understand that, but i have these fields declared in allowedFields property:

PHP Code:
protected $allowedFields = [
        'foo'
        'bar',
        'baz',  
        
'id',
        'fk_loan_id',
        'another_field',
];