It looks like you're new here. If you want to get involved, click one of these buttons!
function form_fields($values = array())
{
// .. code
// unset password field, then set it again to list it at the bottom before the new password field
// see fuel/models/user_model.php
$pwd_field = $fields['password'];
unset($fields['password']);
$user_id = NULL;
if (!empty($values['id']))
{
$user_id = $values['id'];
}
if (!empty($user_id))
{
$fields['new_password'] = array('label' => 'New password', 'type' => 'password');
}
else
{
$pwd_field['type'] = 'password';
$pwd_field['order'] = 50;
$pwd_field['label'] = 'Your password';
$fields['password']= $pwd_field;
}
$fields['confirm_password'] = array('label' => 'Repeat new password', 'type' => 'password', 'order' => 51);
return $fields;
}
function on_before_validate($values)
{
$this->add_validation('email', 'valid_email', lang('error_invalid_email'));
// for new
if (empty($values['id']))
{
// all this stuff works so removed code
}
// for editing
else
{
if (isset($this->normalized_save_data['new_password'])) {
$this->add_validation('new_password', array(&$this, 'is_valid_password'), 'Password is invalid');
}
if (isset($this->normalized_save_data['new_password']) AND isset($this->normalized_save_data['confirm_password']))
{
$this->get_validation()->add_rule('password', 'is_equal_to', lang('error_invalid_password_match'),
array($this->normalized_save_data['new_password'], $this->normalized_save_data['confirm_password']));
//not working either: $this->get_validation()->add_rule('new_password', 'is_equal_to', lang('error_invalid_password_match'),
array($this->normalized_save_data['new_password'], $this->normalized_save_data['confirm_password']));
}
}
return $values;
}
Comments