I have an issue with one of my projects, as soon as I try to update a role I got the following error.
The value in "Role Name" is already being used.
When I am editing/updating the role, the role name shouldn't be validated. Why is this happening?
I've looked into the controller and the model code and it just uses the regular code.
Controller:
if ($type == 'insert') {
$id = $this->role_model->insert($data);
$return = is_numeric($id);
} elseif ($type == 'update') {
$return = $this->role_model->update($id, $data);
}
Model:
public function update($id = null, $data = null)
{
// If this role is set to default, then set all others to NOT be default.
if (isset($data['default']) && $data['default'] == 1) {
$this->db->set('default', 0)
->update($this->table_name);
}
return parent::update($id, $data);
}
Changed the validation rules as suggested by Kisaragi
protected $updateValidationRules = array(
array(
'field' => 'role_name',
'label' => 'lang:role_name',
'rules' => 'required|trim|max_length[60]|unique[roles.role_name,roles.role_id]',
),
);
to
protected $updateValidationRules = array(
array(
'field' => 'role_name',
'label' => 'lang:role_name',
'rules' => 'required|trim|max_length[60]|',
),
);
Thanks a lot.