diff --git a/app/Controllers/Admin/UserController.php b/app/Controllers/Admin/UserController.php
index 87f01db..e15d814 100644
--- a/app/Controllers/Admin/UserController.php
+++ b/app/Controllers/Admin/UserController.php
@@ -61,4 +61,28 @@ class UserController extends AdminController
{
return parent::getFieldBatchFilters();
}
+
+ protected function insert_validate()
+ {
+ $rules = [];
+ foreach ($this->_viewDatas['fieldRules'] as $field => $rule) {
+ switch ($field) {
+ case 'role':
+ $rules['role.*'] = $rule;
+ break;
+ default:
+ $rules[$field] = $rule;
+ break;
+ }
+ }
+ //fieldData Rule 검사
+ if (!$this->validate($rules)) {
+ throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->validator->getErrors()));
+ }
+ //fieldData 적용
+ $this->_viewDatas['fieldDatas'] = array();
+ foreach ($this->_viewDatas['fields'] as $field) {
+ $this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field);
+ }
+ }
}
diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php
index 552d2c0..36cb928 100644
--- a/app/Controllers/BaseController.php
+++ b/app/Controllers/BaseController.php
@@ -3,7 +3,6 @@
namespace App\Controllers;
-use App\Models\UserModel;
use CodeIgniter\Controller;
use CodeIgniter\HTTP\CLIRequest;
use CodeIgniter\HTTP\Files\UploadedFile;
@@ -70,23 +69,6 @@ abstract class BaseController extends Controller
{
return $this->getFieldFilters();
}
- protected function getFieldRule(string $field, array $rules, string $action = ""): array
- {
- switch ($field) {
- default:
- $rules = $this->_model->getFieldRule($field, $rules, $action);
- break;
- }
- return $rules;
- }
- final public function getFieldRules(array $fields, string $action = ""): array
- {
- $rules = array();
- foreach ($fields as $field) {
- $rules = $this->getFieldRule($field, $rules, $action);
- }
- return $rules;
- }
//Field별 Form Datas 처리용
protected function getFieldFormData(string $field, $entity = null): array
{
@@ -144,7 +126,7 @@ abstract class BaseController extends Controller
break;
}
$this->_viewDatas['fields'] = $fields ?: $this->getFields($action);
- $this->_viewDatas['fieldRules'] = $this->getFieldRules($this->_viewDatas['fields'], $action);
+ $this->_viewDatas['fieldRules'] = $this->_model->getFieldRules($this->_viewDatas['fields'], $action);
$this->_viewDatas['fieldFilters'] = $this->getFieldFilters();
$this->_viewDatas['batchjobFilters'] = $this->getFieldBatchFilters();
$this->_viewDatas['fieldFormOptions'] = $this->_model->getFieldFormOptions($this->_viewDatas['fieldFilters']);
diff --git a/app/Models/BaseModel.php b/app/Models/BaseModel.php
index c2fe284..f57d605 100644
--- a/app/Models/BaseModel.php
+++ b/app/Models/BaseModel.php
@@ -106,6 +106,14 @@ abstract class BaseModel extends Model
}
return $rules;
}
+ final public function getFieldRules(array $fields, string $action = ""): array
+ {
+ $rules = array();
+ foreach ($fields as $field) {
+ $rules = $this->getFieldRule($field, $rules, $action);
+ }
+ return $rules;
+ }
//Field별 Form Option용
public function getOptions(array $conditions = array(), $options = array()): array
{
diff --git a/app/Views/admin/board/index.php b/app/Views/admin/board/index.php
index 4737b03..0e4ec9b 100644
--- a/app/Views/admin/board/index.php
+++ b/app/Views/admin/board/index.php
@@ -9,7 +9,7 @@
= form_close(); ?>
- = form_open(current_url() . 'batchjob', $forms['attributes'], $forms['hiddens']) ?>
+ = form_open(current_url() . '/batchjob', $forms['attributes'], $forms['hiddens']) ?>
| 번호 |
@@ -21,12 +21,12 @@
getStatus() != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this);">
|
= form_checkbox(["id" => "checkbox_uid_{$entity->getPrimaryKey()}", "name" => "batchjob_uids[]", "value" => $entity->getPrimaryKey(), "class" => "batchjobuids_checkboxs"]); ?>
- = anchor(current_url() . 'update/' . $entity->getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?>
+ = anchor(current_url() . '/update/' . $entity->getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?>
|
= getFieldIndex_Row_BoardHelper_Admin($field, $entity, $fieldFilters, $fieldFormOptions) ?> |
- = anchor(current_url() . 'delete/' . $entity->getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?> |
+ = anchor(current_url() . '/delete/' . $entity->getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?> |
@@ -36,7 +36,7 @@
= form_checkbox(array("id" => "batchjobuids_checkbox")) ?>ALL
= getFieldFilter_BoardHelper($field, DEFAULTS['EMPTY'], $fieldFormOptions) ?>
= form_submit('', '일괄처리', array("class" => "btn btn-outline btn-warning")); ?>
- = anchor(current_url() . 'insert', '입력', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?>
+ = anchor(current_url() . '/insert', '입력', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?>
= $pagination ?>
diff --git a/app/Views/admin/boardconfig/index.php b/app/Views/admin/boardconfig/index.php
index 8168605..3e28890 100644
--- a/app/Views/admin/boardconfig/index.php
+++ b/app/Views/admin/boardconfig/index.php
@@ -9,7 +9,7 @@
= form_close(); ?>
- = form_open(current_url() . 'batchjob', $forms['attributes'], $forms['hiddens']) ?>
+ = form_open(current_url() . '/batchjob', $forms['attributes'], $forms['hiddens']) ?>
| 번호 |
@@ -21,12 +21,12 @@
getStatus() != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this);">
|
= form_checkbox(["id" => "checkbox_uid_{$entity->getPrimaryKey()}", "name" => "batchjob_uids[]", "value" => $entity->getPrimaryKey(), "class" => "batchjobuids_checkboxs"]); ?>
- = anchor(current_url() . 'update/' . $entity->getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?>
+ = anchor(current_url() . '/update/' . $entity->getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?>
|
= getFieldIndex_Row_BoardConfigHelper_Admin($field, $entity, $fieldFilters, $fieldFormOptions) ?> |
- = anchor(current_url() . 'delete/' . $entity->getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?> |
+ = anchor(current_url() . '/delete/' . $entity->getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?> |
@@ -36,7 +36,7 @@
= form_checkbox(array("id" => "batchjobuids_checkbox")) ?>ALL
= getFieldFilter_BoardConfigHelper($field, DEFAULTS['EMPTY'], $fieldFormOptions) ?>
= form_submit('', '일괄처리', array("class" => "btn btn-outline btn-warning")); ?>
- = anchor(current_url() . 'insert', '입력', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?>
+ = anchor(current_url() . '/insert', '입력', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?>
= $pagination ?>
diff --git a/app/Views/admin/hpilo/index.php b/app/Views/admin/hpilo/index.php
index 6c9a562..d53647a 100644
--- a/app/Views/admin/hpilo/index.php
+++ b/app/Views/admin/hpilo/index.php
@@ -9,7 +9,7 @@
= form_close(); ?>
- = form_open(current_url() . 'batchjob', $forms['attributes'], $forms['hiddens']) ?>
+ = form_open(current_url() . '/batchjob', $forms['attributes'], $forms['hiddens']) ?>
| 번호 |
@@ -21,12 +21,12 @@
getStatus() != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this);">
|
= form_checkbox(["id" => "checkbox_uid_{$entity->getPrimaryKey()}", "name" => "batchjob_uids[]", "value" => $entity->getPrimaryKey(), "class" => "batchjobuids_checkboxs"]); ?>
- = anchor(current_url() . 'update/' . $entity->getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?>
+ = anchor(current_url() . '/update/' . $entity->getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?>
|
= getFieldIndex_Row_HPILOHelper($field, $entity, $fieldFilters, $fieldFormOptions) ?> |
- = anchor(current_url() . 'delete/' . $entity->getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?> |
+ = anchor(current_url() . '/delete/' . $entity->getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?> |
@@ -36,7 +36,7 @@
= form_checkbox(array("id" => "batchjobuids_checkbox")) ?>ALL
= getFieldFilter_HPILOHelper($field, DEFAULTS['EMPTY'], $fieldFormOptions) ?>
= form_submit('', '일괄처리', array("class" => "btn btn-outline btn-warning")); ?>
- = anchor(current_url() . 'insert', '입력', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?>
+ = anchor(current_url() . '/insert', '입력', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?>
= $pagination ?>
diff --git a/app/Views/admin/user/index.php b/app/Views/admin/user/index.php
index 67f1860..57e6a6a 100644
--- a/app/Views/admin/user/index.php
+++ b/app/Views/admin/user/index.php
@@ -9,7 +9,7 @@
= form_close(); ?>
- = form_open(current_url() . 'batchjob', $forms['attributes'], $forms['hiddens']) ?>
+ = form_open(current_url() . '/batchjob', $forms['attributes'], $forms['hiddens']) ?>
| 번호 |
@@ -21,12 +21,12 @@
getStatus() != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this);">
|
= form_checkbox(["id" => "checkbox_uid_{$entity->getPrimaryKey()}", "name" => "batchjob_uids[]", "value" => $entity->getPrimaryKey(), "class" => "batchjobuids_checkboxs"]); ?>
- = anchor(current_url() . 'update/' . $entity->getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?>
+ = anchor(current_url() . '/update/' . $entity->getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?>
|
= getFieldIndex_Row_UserHelper_Admin($field, $entity, $fieldFilters, $fieldFormOptions) ?> |
- = anchor(current_url() . 'delete/' . $entity->getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?> |
+ = anchor(current_url() . '/delete/' . $entity->getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?> |
@@ -36,7 +36,7 @@
= form_checkbox(array("id" => "batchjobuids_checkbox")) ?>ALL
= getFieldFilter_UserHelper($field, DEFAULTS['EMPTY'], $fieldFormOptions) ?>
= form_submit('', '일괄처리', array("class" => "btn btn-outline btn-warning")); ?>
- = anchor(current_url() . 'insert', '입력', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?>
+ = anchor(current_url() . '/insert', '입력', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?>
= $pagination ?>
diff --git a/app/Views/admin/usersns/index.php b/app/Views/admin/usersns/index.php
index 4294d44..b4a08b9 100644
--- a/app/Views/admin/usersns/index.php
+++ b/app/Views/admin/usersns/index.php
@@ -9,7 +9,7 @@
= form_close(); ?>
- = form_open(current_url() . 'batchjob', $forms['attributes'], $forms['hiddens']) ?>
+ = form_open(current_url() . '/batchjob', $forms['attributes'], $forms['hiddens']) ?>
| 번호 |
@@ -21,12 +21,12 @@
getStatus() != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this);">
|
= form_checkbox(["id" => "checkbox_uid_{$entity->getPrimaryKey()}", "name" => "batchjob_uids[]", "value" => $entity->getPrimaryKey(), "class" => "batchjobuids_checkboxs"]); ?>
- = anchor(current_url() . 'update/' . $entity->getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?>
+ = anchor(current_url() . '/update/' . $entity->getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?>
|
= getFieldIndex_Row_UserSNSHelper_Admin($field, $entity, $fieldFilters, $fieldFormOptions) ?> |
- = anchor(current_url() . 'delete/' . $entity->getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?> |
+ = anchor(current_url() . '/delete/' . $entity->getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?> |
@@ -36,7 +36,7 @@
= form_checkbox(array("id" => "batchjobuids_checkbox")) ?>ALL
= getFieldFilter_UserSNSHelper($field, DEFAULTS['EMPTY'], $fieldFormOptions) ?>
= form_submit('', '일괄처리', array("class" => "btn btn-outline btn-warning")); ?>
- = anchor(current_url() . 'insert', '입력', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?>
+ = anchor(current_url() . '/insert', '입력', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?>
= $pagination ?>