diff --git a/app/Controllers/Admin/UserController.php b/app/Controllers/Admin/UserController.php index 0a34536..d05e9d9 100644 --- a/app/Controllers/Admin/UserController.php +++ b/app/Controllers/Admin/UserController.php @@ -41,11 +41,11 @@ class UserController extends AdminController { switch ($field) { case 'role': - $roles = $this->request->getVar($field); + $roles = $this->request->getVar($field) ?? []; if (!count($roles)) { throw new \Exception("권한이 지정되지 않았습니다."); } - $formDatas[$field] = implode(DEFAULTS["DELIMITER_ROLE"],); + $formDatas[$field] = implode(DEFAULTS["DELIMITER_ROLE"], $roles); break; default: $formDatas = parent::getFormData($field, $formDatas); @@ -70,7 +70,7 @@ class UserController extends AdminController switch ($field) { case 'role': //아래 Rule Array는 필드명.* checkbox를 사용 - $this->validation->setRule($field . "*", $field, $this->getModel()->getFieldRule($action, $field)); + $this->validation->setRule($field . ".*", $field, $this->getModel()->getFieldRule($action, $field)); break; default: $this->validation->setRule($field, $field, $this->getModel()->getFieldRule($action, $field)); @@ -82,6 +82,7 @@ class UserController extends AdminController "\n", $this->validation->getErrors() )); + // redirect()->back()->withInput()->with('errors', $this->validation->getErrors()); } } public function create_form(): RedirectResponse|string @@ -103,7 +104,7 @@ class UserController extends AdminController switch ($field) { case 'role': //아래 Rule Array는 필드명.* checkbox를 사용 - $this->validation->setRule($field . "*", $field, $this->getModel()->getFieldRule($action, $field)); + $this->validation->setRule($field . ".*", $field, $this->getModel()->getFieldRule($action, $field)); break; default: $this->validation->setRule($field, $field, $this->getModel()->getFieldRule($action, $field)); diff --git a/app/Helpers/Admin/User_helper.php b/app/Helpers/Admin/User_helper.php index e62380f..878f4c0 100644 --- a/app/Helpers/Admin/User_helper.php +++ b/app/Helpers/Admin/User_helper.php @@ -26,9 +26,8 @@ function getFieldForm_UserHelper(string $field, mixed $value, array $viewDatas, if (in_array($viewDatas['action'], ['create', 'modify'])) { $forms = []; foreach ($viewDatas['field_options'][$field] as $key => $label) { - log_message("debug", var_export($value, true)); $values = is_array($value) ? $value : explode(DEFAULTS["DELIMITER_ROLE"], $value); - $forms[] = form_checkbox($field, $key, in_array($key, $values)) . $label; + $forms[] = form_checkbox($field . "[]", $key, in_array($key, $values)) . $label; } $form = implode(" ", $forms); } else { diff --git a/app/Models/UserModel.php b/app/Models/UserModel.php index 81ade6b..60b982d 100644 --- a/app/Models/UserModel.php +++ b/app/Models/UserModel.php @@ -37,7 +37,7 @@ class UserModel extends CommonModel } switch ($field) { case "id": - $rule = "required|trim|min_length[4]|max_length[20]|is_unique[{$this->table}.{$field}]"; + $rule = "required|trim|min_length[4]|max_length[20]"; $rule .= $action == "create" ? "|is_unique[{$this->table}.{$field}]" : ""; break; case "email": diff --git a/app/Views/layouts/admin.php b/app/Views/layouts/admin.php index 43bbe2a..3b49891 100644 --- a/app/Views/layouts/admin.php +++ b/app/Views/layouts/admin.php @@ -29,9 +29,9 @@
include(LAYOUTS[$viewDatas['layout']]['path'] . '/left_menu'); ?>
-
include('templates/' . $viewDatas['layout'] . '/header'); ?>
+
include('templates/admin/header'); ?>
renderSection('content') ?>
- +
diff --git a/app/Views/layouts/empty.php b/app/Views/layouts/empty.php index 2631393..bfb5042 100644 --- a/app/Views/layouts/empty.php +++ b/app/Views/layouts/empty.php @@ -23,7 +23,9 @@ +
include('templates/empty/header'); ?>
renderSection('content') ?>
+ \ No newline at end of file diff --git a/app/Views/templates/admin/footer.php b/app/Views/templates/admin/footer.php index 58b050d..25d7a63 100644 --- a/app/Views/templates/admin/footer.php +++ b/app/Views/templates/admin/footer.php @@ -1,6 +1,4 @@ -
- getFlashdata(SESSION_NAMES['RETURN_MSG']) ? alert_CommonHelper($viewDatas['session']->getFlashdata(SESSION_NAMES['RETURN_MSG'])) : "" ?> -
+getFlashdata(SESSION_NAMES['RETURN_MSG']) ? alert_CommonHelper($viewDatas['session']->getFlashdata(SESSION_NAMES['RETURN_MSG'])) : "" ?> \ No newline at end of file diff --git a/app/Views/templates/empty/header.php b/app/Views/templates/empty/header.php index 5b6637d..e69de29 100644 --- a/app/Views/templates/empty/header.php +++ b/app/Views/templates/empty/header.php @@ -1 +0,0 @@ -
\ No newline at end of file