fix: [metafield limitation] fixes
- correctly show error messages on user creation when limits are hit - fixed a bug that cause users from being uncreatable even due to a hit limitation, even if the current user wouldn't influence said limitationdevelop
parent
21d03ee585
commit
ef2caed9c8
|
@ -526,10 +526,10 @@ class CRUDComponent extends Component
|
||||||
if (!empty($errors)) {
|
if (!empty($errors)) {
|
||||||
if (count($errors) == 1) {
|
if (count($errors) == 1) {
|
||||||
$field = array_keys($errors)[0];
|
$field = array_keys($errors)[0];
|
||||||
$fieldError = implode(', ', array_values($errors[$field]));
|
$fieldError = json_encode($errors[$field]);
|
||||||
$validationMessage = __('{0}: {1}', $field, $fieldError);
|
$validationMessage = __('{0}: {1}', $field, $fieldError);
|
||||||
} else {
|
} else {
|
||||||
$validationMessage = __('There has been validation issues with multiple fields');
|
$validationMessage = __('There has been validation issues with multiple fields: {0}', json_encode($errors));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $validationMessage;
|
return $validationMessage;
|
||||||
|
|
|
@ -111,7 +111,6 @@ class UsersTable extends AppTable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$enabled && !empty($entity->_metafields_to_delete)) {
|
if (!$enabled && !empty($entity->_metafields_to_delete)) {
|
||||||
foreach ($entity->_metafields_to_delete as $metaFieldToDelete) {
|
foreach ($entity->_metafields_to_delete as $metaFieldToDelete) {
|
||||||
if ($metaFieldToDelete['field'] === $permission_name) {
|
if ($metaFieldToDelete['field'] === $permission_name) {
|
||||||
|
@ -120,7 +119,7 @@ class UsersTable extends AppTable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($valueToCompareTo > $permission_data['limit']) {
|
if ($enabled && $valueToCompareTo > $permission_data['limit']) {
|
||||||
return [
|
return [
|
||||||
$permission_name =>
|
$permission_name =>
|
||||||
__(
|
__(
|
||||||
|
@ -202,7 +201,7 @@ class UsersTable extends AppTable
|
||||||
foreach ($permissionRestrictionCheck as $permission_name => $errors) {
|
foreach ($permissionRestrictionCheck as $permission_name => $errors) {
|
||||||
foreach ($entity->meta_fields as $i => $metaField) {
|
foreach ($entity->meta_fields as $i => $metaField) {
|
||||||
if ($metaField['field'] === $permission_name) {
|
if ($metaField['field'] === $permission_name) {
|
||||||
$entity->meta_fields[$i]->setErrors(['value' => $errors]);
|
$entity->setErrors(['meta_fields' => [$permission_name => $errors]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue