on_before_save/validate additional field value
Hi,
I have a field "password" in my model, but I dont' want to show it in the form editing in the admin area, so changed this method:
function form_fields($values = array())
{
$fields = parent::form_fields();
// Add new field to new passord
$fields['password']['type'] = 'hidden';
$fields['new_password']['order'] = 3;
$fields['new_password']['value'] = '';
return $fields;
}
So, now it should hide 'password' field, and create new field 'new_password'. And this works great. But I need to save value from 'new_password' to 'password' field, and I use functions on_before_save/validate.
function on_before_save($values)
{
$values['password'] = $values['new_password'];
return $values;
}
The problem is, there is no 'new_password' in variable $values, only 'password', so I got error "Unknown variable ''new_password".
The same situation with on_before_validation().
Only on_after_post() variable $values has "new_password", but this function can't change date before save.
Please, help me with this issue. Thanks.
Comments
function on_before_save($values) { if (isset($this->normalized_save_data['new_password'])) { $values['password'] = $this->normalized_save_data['new_password']; } return $values; }