This commit is contained in:
kali
2024-04-16 17:13:42 +03:00
parent 87deac2576
commit a3faec247e
10 changed files with 42 additions and 419 deletions

1
views/admin/ajax.php Normal file
View File

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

View File

@ -15,28 +15,19 @@ use itguild\forms\inputs\TextArea;
])
->setLabel("Название формы")
->render();
$form->field(TextArea::class, name: "params", 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>
<?php
$form->field(\itguild\forms\inputs\Button::class, name: "btn-submit", params: [
'class' => "btn btn-primary ",
'value' => 'Отправить',
'typeInput' => 'submit'
])
->render();
$form->endForm();
?>
<script>
$.ajax({
url:'/handler.php',
method: 'post',
dataType: 'html'
data: {element: 'value', abc:'test'},
success: function (data){
console.log(<<Sent successfully: >> + data);
}
});
</script>
<?php $form->endForm(); ?>

View File

@ -9,9 +9,10 @@
<head>
<meta charset="UTF-8">
<title><?php echo $title ?></title>
<link rel="stylesheet" href="vendor/twbs/bootstrap/dist/css/bootstrap.css">
<link rel="stylesheet" href="/vendor/twbs/bootstrap/dist/css/bootstrap.css">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous" />
<script src="/public/js/ajax.js"></script>
</head>
<body>
<div class="container">