diff --git a/admin/roles/classes/define_role_table_advanced.php b/admin/roles/classes/define_role_table_advanced.php index c0e3d8d5ab8af..6fb58c6b25ff9 100644 --- a/admin/roles/classes/define_role_table_advanced.php +++ b/admin/roles/classes/define_role_table_advanced.php @@ -158,19 +158,19 @@ public function read_submitted_permissions() { // Allowed roles. $allow = optional_param_array('allowassign', null, PARAM_INT); if (!is_null($allow)) { - $this->allowassign = $allow; + $this->allowassign = array_filter($allow); } $allow = optional_param_array('allowoverride', null, PARAM_INT); if (!is_null($allow)) { - $this->allowoverride = $allow; + $this->allowoverride = array_filter($allow); } $allow = optional_param_array('allowswitch', null, PARAM_INT); if (!is_null($allow)) { - $this->allowswitch = $allow; + $this->allowswitch = array_filter($allow); } $allow = optional_param_array('allowview', null, PARAM_INT); if (!is_null($allow)) { - $this->allowview = $allow; + $this->allowview = array_filter($allow); } // Now read the permissions for each capability. @@ -619,7 +619,9 @@ protected function get_allow_role_control($type) { if ($this->roleid == 0) { $options[-1] = get_string('thisnewrole', 'core_role'); } - return html_writer::select($options, 'allow'.$type.'[]', $selected, false, array('multiple' => 'multiple', + return + html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'allow'.$type.'[]', 'value' => "")) . + html_writer::select($options, 'allow'.$type.'[]', $selected, false, array('multiple' => 'multiple', 'size' => 10, 'class' => 'form-control')); }