bd 9.0
This commit is contained in:
parent
13dbef5b4f
commit
f26754ca79
@ -15,10 +15,12 @@ function ajaxRequest() {
|
||||
}
|
||||
function getValueSelect(){
|
||||
var selectValue = document.getElementById("selectID").value
|
||||
var inputTags = document.getElementsByTagName('input');
|
||||
var inputCount = inputTags.length - 3;
|
||||
var request = new XMLHttpRequest()
|
||||
request.open("GET", "/admin/set-value-select?value=" + selectValue + "&count=" + inputCount, true)
|
||||
var request = new XMLHttpRequest();
|
||||
let button = document.getElementById("buttonAdd");
|
||||
let count = parseInt(button.dataset.count) + 1;
|
||||
button.dataset.count = count;
|
||||
console.log(count);
|
||||
request.open("GET", "/admin/set-value-select?value=" + selectValue + "&count=" + count, true)
|
||||
request.addEventListener("load", () => {
|
||||
var responseText = request.responseText;
|
||||
var targetElement = document.getElementById("buttonAdd");
|
||||
|
@ -4,6 +4,7 @@ namespace itguild\forms;
|
||||
|
||||
use itguild\forms\builders\ButtonBuilder;
|
||||
use itguild\forms\builders\CheckBoxBuilder;
|
||||
use itguild\forms\builders\HiddenBuilder;
|
||||
use itguild\forms\builders\RadioButtonBuilder;
|
||||
use itguild\forms\builders\SelectBuilder;
|
||||
use itguild\forms\builders\TextAreaBuilder;
|
||||
@ -12,6 +13,7 @@ use itguild\forms\debug\Debug;
|
||||
use itguild\forms\inputs\BaseInput;
|
||||
use itguild\forms\inputs\Button;
|
||||
use itguild\forms\inputs\Checkbox;
|
||||
use itguild\forms\inputs\Hidden;
|
||||
use itguild\forms\inputs\RadioButton;
|
||||
use itguild\forms\inputs\Select;
|
||||
use itguild\forms\inputs\TextArea;
|
||||
@ -61,6 +63,9 @@ class ActiveForm
|
||||
elseif ($class === RadioButton::class){
|
||||
$this->fieldObject = RadioButtonBuilder::build($name, $params);
|
||||
}
|
||||
elseif ($class === Hidden::class){
|
||||
$this->fieldObject = HiddenBuilder::build($name, $params);
|
||||
}
|
||||
else {
|
||||
$this->fieldObject = new $class($name, $params);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ namespace itguild\forms\app\controllers;
|
||||
use Illuminate\Database\Events\DatabaseBusy;
|
||||
use itguild\forms\ActiveForm;
|
||||
use itguild\forms\app\core\BaseController;
|
||||
use itguild\forms\app\models\FormInputModel;
|
||||
use itguild\forms\app\models\FormModel;
|
||||
use itguild\forms\core\cg_view\CgView;
|
||||
|
||||
@ -31,12 +32,25 @@ class AdminController extends BaseController
|
||||
}
|
||||
public function saveFormAction(): void
|
||||
{
|
||||
|
||||
$title = $_POST["title"];
|
||||
$params = $_POST["params"];
|
||||
if (isset($title) and isset($params)) {
|
||||
$form = FormModel::Create(['title' => $title, 'status' => FormModel::STATUS_ACTIVE, 'params' => $params]);
|
||||
echo "Форма сохранена!";
|
||||
$perPage = $_POST['perPage'];
|
||||
$inputs = $_POST["InputForm"];
|
||||
$inputArray = [];
|
||||
foreach ($inputs as $input){
|
||||
$form = FormInputModel::Create(['form_id' => 42, 'input_type_id' => $input['type'], 'label' => $input['name'], 'name' => 'adsads', 'params' => "adsasd"]);
|
||||
Debug::prn($form);
|
||||
|
||||
}
|
||||
|
||||
$resultArray = ['meta' => ['perpage' => $perPage]];
|
||||
|
||||
Debug::prn(json_encode($resultArray, true));
|
||||
|
||||
//if (isset($title) and isset($params)) {
|
||||
// $form = FormModel::Create(['title' => $title, 'status' => FormModel::STATUS_ACTIVE, 'params' => json_encode($resultArray, true)]);
|
||||
// echo "Форма сохранена!";
|
||||
//}//
|
||||
}
|
||||
public function getFormAddFieldsAction(): void
|
||||
{
|
||||
@ -46,7 +60,6 @@ class AdminController extends BaseController
|
||||
{
|
||||
$selectValue = $_GET["value"];
|
||||
$countInput = $_GET["count"];
|
||||
Debug::prn($countInput);
|
||||
$form = new ActiveForm();
|
||||
|
||||
$fields = [
|
||||
@ -64,9 +77,10 @@ class AdminController extends BaseController
|
||||
throw new FieldTypeNotFound($selectValue);
|
||||
}
|
||||
|
||||
$this->cgView->render("/admin/field_type/$viewName.php", ['form' => new ActiveForm()]);
|
||||
$this->cgView->render("/admin/field_type/$viewName.php", ['form' => new ActiveForm(), 'count' => $countInput]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -9,6 +9,8 @@
|
||||
use itguild\forms\inputs\Checkbox;
|
||||
use itguild\forms\inputs\TextInput;
|
||||
|
||||
$form->field(TextInput::class, name: "NameInput", params: ['class' => "form-control",
|
||||
'placeholder' => "Наименование"])->setLabel("Наименование (например \"Телефон\")")->render();
|
||||
$form->field(Checkbox::class, name: "RequiredInput", params:[])->setLabel("Обязательное")->render();
|
||||
|
||||
$form->field(TextInput::class, name: "InputForm[$count][name]", params: ['class' => "form-control",
|
||||
'placeholder' => "Наименование поля"])->setLabel("Наименование поля (например \"Телефон\")")->render();
|
||||
$form->field(Checkbox::class, name: "InputForm[$count][required]", params:['value' => '1'])->setLabel("Обязательное")->render();
|
||||
$form->field(\itguild\forms\inputs\Hidden::class, name: "InputForm[$count][type]", params: ['value' => '5'])->render();
|
||||
|
@ -3,12 +3,14 @@
|
||||
/**
|
||||
*
|
||||
* @var \itguild\forms\ActiveForm $form
|
||||
* @var integer $count
|
||||
*
|
||||
*/
|
||||
|
||||
use itguild\forms\inputs\Checkbox;
|
||||
use itguild\forms\inputs\TextInput;
|
||||
|
||||
$form->field(TextInput::class, name: "NameInput", params: ['class' => "form-control",
|
||||
$form->field(TextInput::class, name: "InputForm[$count][name]", params: ['class' => "form-control",
|
||||
'placeholder' => "Наименование"])->setLabel("Наименование (например \"Телефон\")")->render();
|
||||
$form->field(Checkbox::class, name: "RequiredInput", params:[])->setLabel("Обязательное")->render();
|
||||
$form->field(Checkbox::class, name: "InputForm[$count][required]", params:['value' => '1'])->setLabel("Обязательное")->render();
|
||||
$form->field(\itguild\forms\inputs\Hidden::class, name: "InputForm[$count][type]", params: ['value' => '1'])->render();
|
@ -9,6 +9,7 @@
|
||||
use itguild\forms\inputs\Checkbox;
|
||||
use itguild\forms\inputs\TextInput;
|
||||
|
||||
$form->field(TextInput::class, name: "NameInput", params: ['class' => "form-control",
|
||||
$form->field(TextInput::class, name: "InputForm[$count][name]", params: ['class' => "form-control",
|
||||
'placeholder' => "Наименование"])->setLabel("Наименование (например \"Телефон\")")->render();
|
||||
$form->field(Checkbox::class, name: "RequiredInput", params:[])->setLabel("Обязательное")->render();
|
||||
$form->field(Checkbox::class, name: "InputForm[$count][required]", params:['value' => '1'])->setLabel("Обязательное")->render();
|
||||
$form->field(\itguild\forms\inputs\Hidden::class, name: "InputForm[$count][type]", params: ['value' => '4'])->render();
|
@ -10,13 +10,11 @@ use itguild\forms\inputs\Checkbox;
|
||||
use itguild\forms\inputs\TextArea;
|
||||
use itguild\forms\inputs\TextInput;
|
||||
|
||||
$form->field(TextInput::class, name: "NameInput", params: ['class' => "form-control",
|
||||
'placeholder' => "Наименование поля"])
|
||||
->setLabel("Наименование поля (например \"Телефон\")")
|
||||
->render();
|
||||
$form->field(TextArea::class, name: "OptionsInput", params: ['class' => "form-control"])
|
||||
|
||||
$form->field(TextInput::class, name: "InputForm[$count][name]", params: ['class' => "form-control",
|
||||
'placeholder' => "Наименование"])->setLabel("Наименование (например \"Телефон\")")->render();
|
||||
$form->field(TextArea::class, name: "InputForm[$count][options]", params: ['class' => "form-control"])
|
||||
->setLabel("Опции выпадающего списка")
|
||||
->render();
|
||||
$form->field(Checkbox::class, name: "RequiredInput", params:[])
|
||||
->setLabel("Обязательное поле")
|
||||
->render();
|
||||
$form->field(Checkbox::class, name: "InputForm[$count][required]", params:['value' => '1'])->setLabel("Обязательное")->render();
|
||||
$form->field(\itguild\forms\inputs\Hidden::class, name: "InputForm[$count][type]", params: ['value' => '6'])->render();
|
@ -3,14 +3,16 @@
|
||||
/**
|
||||
*
|
||||
* @var \itguild\forms\ActiveForm $form
|
||||
* @var integer $count
|
||||
*
|
||||
*/
|
||||
|
||||
use itguild\forms\inputs\Checkbox;
|
||||
use itguild\forms\inputs\TextInput;
|
||||
|
||||
$form->field(TextInput::class, name: "NameInput", params: ['class' => "form-control",
|
||||
$form->field(TextInput::class, name: "InputForm[$count][name]", params: ['class' => "form-control",
|
||||
'placeholder' => "Наименование поля"])->setLabel("Наименование поля (например \"Телефон\")")->render();
|
||||
$form->field(TextInput::class, name: "PlaceholderInput", params: ['class' => "form-control",
|
||||
$form->field(TextInput::class, name: "InputForm[$count][placeholder]", params: ['class' => "form-control",
|
||||
'placeholder' => 'Placeholder'])->setLabel("Placeholder")->render();
|
||||
$form->field(Checkbox::class, name: "RequiredInput", params:[])->setLabel("Обязательное поле")->render();
|
||||
$form->field(Checkbox::class, name: "InputForm[$count][required]", params:['value' => '1'])->setLabel("Обязательное")->render();
|
||||
$form->field(\itguild\forms\inputs\Hidden::class, name: "InputForm[$count][type]", params: ['value' => '2'])->render();
|
@ -9,8 +9,9 @@
|
||||
use itguild\forms\inputs\Checkbox;
|
||||
use itguild\forms\inputs\TextInput;
|
||||
|
||||
$form->field(TextInput::class, name: "NameInput", params: ['class' => "form-control",
|
||||
$form->field(TextInput::class, name: "InputForm[$count][name]", params: ['class' => "form-control",
|
||||
'placeholder' => "Наименование поля"])->setLabel("Наименование поля (например \"Телефон\")")->render();
|
||||
$form->field(TextInput::class, name: "PlaceholderInput", params: ['class' => "form-control",
|
||||
$form->field(TextInput::class, name: "InputForm[$count][placeholder]", params: ['class' => "form-control",
|
||||
'placeholder' => 'Placeholder'])->setLabel("Placeholder")->render();
|
||||
$form->field(Checkbox::class, name: "RequiredInput", params:[])->setLabel("Обязательное поле")->render();
|
||||
$form->field(Checkbox::class, name: "InputForm[$count][required]", params:['value' => '1'])->setLabel("Обязательное")->render();
|
||||
$form->field(\itguild\forms\inputs\Hidden::class, name: "InputForm[$count][type]", params: ['value' => '3'])->render();
|
@ -24,12 +24,7 @@ $form->field(TextInput::class, name: "perPage", params: [
|
||||
])
|
||||
->setLabel("Количество выводимых записей на страницу")
|
||||
->render();
|
||||
$form->field(TextArea::class, name: "paramsForm", params: [
|
||||
'class' => "form-control",
|
||||
'placeholder' => 'Параметры'
|
||||
])
|
||||
->setLabel("Параметры")
|
||||
->render();
|
||||
|
||||
$form->field(\itguild\forms\inputs\Select::class, name: "inputType", params: [
|
||||
'class' => "form-control-sm",
|
||||
'id' => "selectID",
|
||||
@ -39,7 +34,7 @@ $form->field(\itguild\forms\inputs\Select::class, name: "inputType", params: [
|
||||
->setLabel("Добавить поле")
|
||||
->render();
|
||||
?>
|
||||
<button style="margin-top:15px" type="button" id="buttonAdd" class="btn btn-success " onclick="getValueSelect()">Добавить поле</button>
|
||||
<button style="margin-top:15px" type="button" id="buttonAdd" class="btn btn-success " onclick="getValueSelect()" data-count=0>Добавить поле</button>
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user