cfmgrv4 init...4

This commit is contained in:
최준흠 2024-10-02 22:38:50 +09:00
parent 54e067a1c4
commit 0f431a40e7
8 changed files with 76 additions and 15 deletions

View File

@ -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));

View File

@ -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 {

View File

@ -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":

View File

@ -29,9 +29,9 @@
<div class="middle">
<div class="left"><?= $this->include(LAYOUTS[$viewDatas['layout']]['path'] . '/left_menu'); ?></div>
<div class="center">
<div class="header"><?= $this->include('templates/' . $viewDatas['layout'] . '/header'); ?></div>
<div class="header"><?= $this->include('templates/admin/header'); ?></div>
<div class="content"><?= $this->renderSection('content') ?></div>
<div class="footer"><?= $this->include('templates/' . $viewDatas['layout'] . '/footer'); ?></div>
<div class="footer"><?= $this->include('templates/admin/footer'); ?></div>
</div>
</div>
<div class="bottom">

View File

@ -23,7 +23,9 @@
</head>
<body>
<div class="header"><?= $this->include('templates/empty/header'); ?></div>
<div class="content"><?= $this->renderSection('content') ?></div>
<div class="footer"><?= $this->include('templates/empty/footer'); ?></div>
</body>
</html>

View File

@ -1,6 +1,4 @@
<div>
<?= $viewDatas['session']->getFlashdata(SESSION_NAMES['RETURN_MSG']) ? alert_CommonHelper($viewDatas['session']->getFlashdata(SESSION_NAMES['RETURN_MSG'])) : "" ?>
</div>
<?= $viewDatas['session']->getFlashdata(SESSION_NAMES['RETURN_MSG']) ? alert_CommonHelper($viewDatas['session']->getFlashdata(SESSION_NAMES['RETURN_MSG'])) : "" ?>
<script type="text/javascript">
$(document).ready(function() {
//class가 calender인 inputbox용,날짜field용

View File

@ -1,2 +1,64 @@
<div class="footer"></div>
<?= $viewDatas['session']->getFlashdata('return_message') ? alert_CommonHelper($viewDatas['session']->getFlashdata('return_message')) : "" ?>
<?= $viewDatas['session']->getFlashdata(SESSION_NAMES['RETURN_MSG']) ? alert_CommonHelper($viewDatas['session']->getFlashdata(SESSION_NAMES['RETURN_MSG'])) : "" ?>
<script type="text/javascript">
$(document).ready(function() {
//class가 calender인 inputbox용,날짜field용
$(".calender").datepicker({
changeYear: true,
changeMonth: true,
yearRange: "-10:+0",
dateFormat: "yy-mm-dd"
});
//id가 batchjobuids_checkbox인 버튼을 클릭시 class가 batchjobuids_checkboxs인 checkbox용
$('#batchjobuids_checkbox').click(function(event) {
if (this.checked) {
$('.batchjobuids_checkboxs').each(function() { //loop checkbox
$(this).prop('checked', true); //check
});
} else {
$('.batchjobuids_checkboxs').each(function() { //loop checkbox
$(this).prop('checked', false); //uncheck
});
}
});
//class가 select-field인 SelectBox용
$(".select-field").select2({
theme: "classic",
width: 'style',
dropdownAutoWidth: true
});
// text editor 초기화
//참고: https://phppot.com/menu/php/learn-php/
// class가 editor인 textarea용
tinymce.init({
selector: 'textarea.editor',
plugins: ['code', 'image', 'preview', 'table', 'emoticons', 'autoresize'],
height: 600,
// content_style: 'body { font-family:Helvetica,Arial,sans-serif; font-size:16px }'
automatic_uploads: false,
images_upload_url: '/tinymce_upload.php',
// images_upload_base_path: '/upload_images',
images_upload_handler: function(blobInfo, success, failure) {
var xhr, formData;
xhr = new XMLHttpRequest();
xhr.withCredentials = false;
xhr.open('POST', '/tinymce_upload.php');
xhr.onload = function() {
var json;
if (xhr.status != 200) {
failure('HTTP Error: ' + xhr.status);
return;
}
json = JSON.parse(xhr.responseText);
if (!json || typeof json.file_path != 'string') {
failure('Invalid JSON: ' + xhr.responseText);
return;
}
success(json.file_path);
};
formData = new FormData();
formData.append('file', blobInfo.blob(), blobInfo.filename());
xhr.send(formData);
},
});
});
</script>

View File

@ -1 +0,0 @@
<div class="header"></div>