diff --git a/app/Controllers/CommonController.php b/app/Controllers/CommonController.php index e6c4d83..c2684ca 100644 --- a/app/Controllers/CommonController.php +++ b/app/Controllers/CommonController.php @@ -160,6 +160,12 @@ abstract class CommonController extends BaseController { return $this->_control['filter_optons'][$field]; } + final protected function setFilterValues(): void + { + foreach ($this->getFilterFields() as $field) { + $this->_control[$field] = $this->request->getVar($field); + } + } protected function initAction(string $action, $fields = []): void { //각 Field 초기화 @@ -281,15 +287,10 @@ abstract class CommonController extends BaseController //각 Field 초기화 // $this->getMyAuth()->pushCurrentUrl($this->request->getUri()->getPath() . ($this->request->getUri()->getQuery() ? "?" . $this->request->getUri()->getQuery() : "")); $this->initAction(__FUNCTION__); - helper(['form']); //filter_fields에 해당하는 값이 있을 경우 정의 - foreach ($this->getFilterFields() as $field) { - $value = $this->request->getVar($field); - if ($value) { - $this->$field = $value; - } - } + $this->setFilterValues(); $this->create_form_process(); + helper(['form']); $this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []]; return $this->getResultSuccess(); } catch (\Exception $e) { @@ -333,20 +334,15 @@ abstract class CommonController extends BaseController //각 Field 초기화 // $this->getMyAuth()->pushCurrentUrl($this->request->getUri()->getPath() . ($this->request->getUri()->getQuery() ? "?" . $this->request->getUri()->getQuery() : "")); $this->initAction(__FUNCTION__); - helper(['form']); //filter_fields에 해당하는 값이 있을 경우 정의 - foreach ($this->getFilterFields() as $field) { - $value = $this->request->getVar($field); - if ($value) { - $this->$field = $value; - } - } + $this->setFilterValues(); //기존 Entity 가져오기 $entity = $this->getService()->getEntity($uid); if (!$entity) { throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다."); } $this->modify_form_process($entity); + helper(['form']); $this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []]; return $this->getResultSuccess(); } catch (\Exception $e) { @@ -547,20 +543,15 @@ abstract class CommonController extends BaseController foreach ($this->getViewFields() as $field) { $this->setFieldRule($field, $this->getFormFieldRule($this->getAction(), $field)); } - helper(['form']); + //filter_fields에 해당하는 값이 있을 경우 정의 + $this->setFilterValues(); //기존 Entity 가져오기 $entity = $this->getService()->getEntity($uid); if (!$entity) { throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다."); } - //filter_fields에 해당하는 값이 있을 경우 정의 - foreach ($this->getFilterFields() as $field) { - $value = $this->request->getVar($field); - if ($value) { - $this->$field = $value; - } - } $this->view_process($entity); + helper(['form']); $this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []]; return $this->getResultSuccess(); } catch (\Exception $e) { @@ -572,13 +563,11 @@ abstract class CommonController extends BaseController //Filter 조건절 처리 protected function setFilterConditionForList(): void { - if (!array_key_exists('filter_datas', $this->_control)) { - $this->_control['filter_values'] = []; - } + //filter_fields에 해당하는 값이 있을 경우 정의 + $this->setFilterValues(); foreach ($this->getFilterFields() as $field) { - $this->_control['filter_values'][$field] = $this->request->getVar($field); - if ($this->_control['filter_values'][$field] !== null && $this->_control['filter_values'][$field] !== '') { - $this->getService()->getModel()->where("{$this->getService()->getModel()->getTable()}.{$field}", $this->_control['filter_values'][$field]); + if ($this->_control[$field] !== null && $this->_control[$field] !== '') { + $this->getService()->getModel()->where("{$this->getService()->getModel()->getTable()}.{$field}", $this->_control[$field]); } } } diff --git a/app/Helpers/Customer/ServiceItemHelper.php b/app/Helpers/Customer/ServiceItemHelper.php index 95cdb4f..f91be14 100644 --- a/app/Helpers/Customer/ServiceItemHelper.php +++ b/app/Helpers/Customer/ServiceItemHelper.php @@ -18,7 +18,7 @@ class ServiceItemHelper extends CustomerHelper final function getFieldFormByByItemType(string $field, mixed $value, array $viewDatas, array $extras = []): string { // dd($viewDatas['control']); - $item_type = $viewDatas['control']['filter_values']['item_type']; + $item_type = $viewDatas['control']['item_type']; //Field는 item_uid이지만 , item_tpe에 따라 filter_options가 달라진다. switch ($item_type) { case "IP": diff --git a/app/Views/admin/create_form.php b/app/Views/admin/create_form.php index 71f4d8b..08e3faf 100644 --- a/app/Views/admin/create_form.php +++ b/app/Views/admin/create_form.php @@ -10,7 +10,7 @@