From 05cbb7ef435eee9c075e9ce38f1d3a5653839484 Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 16 Apr 2024 17:54:37 +0300 Subject: [PATCH] bd 7.0 --- public/js/ajax.js | 7 +++++-- src/app/controllers/AdminController.php | 27 +++++++++++++++++++++---- views/admin/ajax.php | 1 - views/admin/index.php | 13 +++++++++++- 4 files changed, 40 insertions(+), 8 deletions(-) delete mode 100644 views/admin/ajax.php diff --git a/public/js/ajax.js b/public/js/ajax.js index 6e5957a..9c6449f 100644 --- a/public/js/ajax.js +++ b/public/js/ajax.js @@ -4,8 +4,11 @@ function ajaxRequest() { request.addEventListener("load", () => { const responseText = request.responseText; const targetElement = document.getElementById("buttonAdd"); - - targetElement.insertAdjacentHTML("beforebegin", responseText); + const divElement = document.createElement("div"); + divElement.classList.add("form-control"); + divElement.style.backgroundColor = "#bbbbbb"; // Задайте здесь свой нужный стиль + divElement.innerHTML = responseText; + targetElement.insertAdjacentElement("beforebegin", divElement); }); request.send(); diff --git a/src/app/controllers/AdminController.php b/src/app/controllers/AdminController.php index 16a5e0b..b345096 100644 --- a/src/app/controllers/AdminController.php +++ b/src/app/controllers/AdminController.php @@ -12,6 +12,7 @@ use itguild\forms\core\cg_view\CgView; */ use itguild\forms\Form; +use itguild\forms\inputs\Select; use itguild\forms\inputs\TextInput; use itguild\forms\inputs\TextArea; class AdminController extends BaseController @@ -41,11 +42,29 @@ class AdminController extends BaseController public function ajax() { $form = new ActiveForm(); - $form->field(TextInput::class, name: "title", params: [ - 'class' => "form-control", - 'placeholder' => 'Название формы' + + $form->field(Select::class, name: "selectItem", params: [ + 'class' => "form-control", "options" => ["textInput", "textArea", "checkBox", "button", "radioButton", "select", "label"] ]) - ->setLabel("Название формы") + ->setLabel("Выберите тип инпута") + ->render(); + $form->field(TextInput::class, name: "name", params: [ + 'class' => "form-control", + 'placeholder' => 'Name' + ]) + ->setLabel("Имя поля") + ->render(); + $form->field(TextInput::class, name: "value", params: [ + 'class' => "form-control", + 'placeholder' => 'Значение value' + ]) + ->setLabel("Значение") + ->render(); + $form->field(TextArea::class, name: "value", params: [ + 'class' => "form-control", + 'placeholder' => 'Параметры поля' + ]) + ->setLabel("Параметры") ->render(); } diff --git a/views/admin/ajax.php b/views/admin/ajax.php deleted file mode 100644 index b3d9bbc..0000000 --- a/views/admin/ajax.php +++ /dev/null @@ -1 +0,0 @@ -setLabel("Название формы") ->render(); - +$form->field(TextInput::class, name: "title", params: [ + 'class' => "form-control", + 'placeholder' => 'Perpage' +]) + ->setLabel("Количество выводимых записей на страницу") + ->render(); +$form->field(TextArea::class, name: "title", params: [ + 'class' => "form-control", + 'placeholder' => 'Параметры' +]) + ->setLabel("Параметры") + ->render(); ?>