This commit is contained in:
kali 2024-04-16 17:54:37 +03:00
parent a3faec247e
commit 05cbb7ef43
4 changed files with 40 additions and 8 deletions

View File

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

View File

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

View File

@ -1 +0,0 @@
<?php

View File

@ -16,7 +16,18 @@ use itguild\forms\inputs\TextArea;
->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();
?>
<button style="margin-top:15px" type="button" id="buttonAdd" class="btn btn-primary form-control" onclick="ajaxRequest()">Добавить поле</button>