diff --git a/checkPOST.php b/checkPOST.php
new file mode 100644
index 0000000..2d12f42
--- /dev/null
+++ b/checkPOST.php
@@ -0,0 +1,21 @@
+ $_POST['phone'],
+ "email" => $_POST['email'],
+ "name" => $_POST['name'],
+ "lastname" => $_POST['lastname'],
+ "button" => $_POST['Button'],
+ "radio1" => $_POST['radio1'],
+ "textarea" => $_POST['textarea'],
+ "select" => $_POST['select'],
+ "one" => $_POST['one'],
+ "two" => $_POST['two'],
+ "radio2" => $_POST['radio2'],
+ "select2" => $_POST['select2']
+
+];
+$jsonData = json_encode($formData);
+
+$file = "form.json";
+file_put_contents($file, $jsonData);
diff --git a/composer.json b/composer.json
index a1f8c3b..1144337 100644
--- a/composer.json
+++ b/composer.json
@@ -11,5 +11,7 @@
"name": "nikita"
}
],
- "require": {}
+ "require": {
+ "twbs/bootstrap": "5.0.2"
+ }
}
diff --git a/composer.lock b/composer.lock
new file mode 100644
index 0000000..4356d2b
--- /dev/null
+++ b/composer.lock
@@ -0,0 +1,69 @@
+{
+ "_readme": [
+ "This file locks the dependencies of your project to a known state",
+ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
+ "This file is @generated automatically"
+ ],
+ "content-hash": "1b775feba4907582ffe0d09797b8c9bf",
+ "packages": [
+ {
+ "name": "twbs/bootstrap",
+ "version": "v5.0.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/twbs/bootstrap.git",
+ "reference": "688bce4fa695cc360a0d084e34f029b0c192b223"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/twbs/bootstrap/zipball/688bce4fa695cc360a0d084e34f029b0c192b223",
+ "reference": "688bce4fa695cc360a0d084e34f029b0c192b223",
+ "shasum": ""
+ },
+ "replace": {
+ "twitter/bootstrap": "self.version"
+ },
+ "type": "library",
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Mark Otto",
+ "email": "markdotto@gmail.com"
+ },
+ {
+ "name": "Jacob Thornton",
+ "email": "jacobthornton@gmail.com"
+ }
+ ],
+ "description": "The most popular front-end framework for developing responsive, mobile first projects on the web.",
+ "homepage": "https://getbootstrap.com/",
+ "keywords": [
+ "JS",
+ "css",
+ "framework",
+ "front-end",
+ "mobile-first",
+ "responsive",
+ "sass",
+ "web"
+ ],
+ "support": {
+ "issues": "https://github.com/twbs/bootstrap/issues",
+ "source": "https://github.com/twbs/bootstrap/tree/v5.0.2"
+ },
+ "time": "2021-06-22T18:29:16+00:00"
+ }
+ ],
+ "packages-dev": [],
+ "aliases": [],
+ "minimum-stability": "stable",
+ "stability-flags": [],
+ "prefer-stable": false,
+ "prefer-lowest": false,
+ "platform": [],
+ "platform-dev": [],
+ "plugin-api-version": "2.6.0"
+}
diff --git a/example.php b/example.php
new file mode 100644
index 0000000..47258f2
--- /dev/null
+++ b/example.php
@@ -0,0 +1,193 @@
+
+
+
+
+
+
+
+ Document
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/form.json b/form.json
new file mode 100644
index 0000000..17a7003
--- /dev/null
+++ b/form.json
@@ -0,0 +1,18 @@
+{
+ "textInpt": {
+ "name": "email",
+ "placeholder": "Email",
+ "id": "EmailId"
+ },
+ "email": "dsadas@dsadsa",
+ "name": "1",
+ "lastname": "edas",
+ "button": "3",
+ "radio1": "on",
+ "textarea": "dsadasads",
+ "select": "class3",
+ "one": "ads",
+ "two": "dsa",
+ "radio2": "on",
+ "select2": "1"
+}
\ No newline at end of file
diff --git a/index.php b/index.php
index d248bfe..cdf103a 100644
--- a/index.php
+++ b/index.php
@@ -11,8 +11,10 @@ error_reporting(-1);
require_once "vendor/autoload.php";
+$formData = [];
+
$form = new Form();
-$form->beginForm("tsad");
+$form->beginForm("checkPOST.php");
$form->textInput("phone", ['placeholder' => 'Введите телефон', 'class' => 'form-group']);
$form->textInput("email", ['placeholder' => 'Введите email']);
$form->textInput("name", ['type' => 'number']);
@@ -21,30 +23,33 @@ $form->checkBox("Button", "1", ["class" => 'sdsa', "id" => "b1"]);
$form->checkBox("Button", "2", ["class" => 'sdsa', "id" => "b1"]);
$form->checkBox("Button", "3", ["class" => 'sdsa', "id" => "b1"]);
$form->label("RadioButton", ["for" => "r2"]);
-$form->radio("name1", ["id" => "r2"]);
+$form->radio("radio1", ["id" => "r2"]);
$form->label("RadioButton", ["for" => "r3"]);
-$form->radio("name1", ["id" => "r3"]);
+$form->radio("radio1", ["id" => "r3"]);
$form->textarea("textarea", "dsadasads", ["id" => "t1"]);
$form->select("select", ["class1" => "option", "class2" => "b2", "class3" => "b4"], 'class2', ["id" => "s1"]);
-$form->button('button', "Кнопка", ["id" => "button"]);
-$form->endForm();
+
$activeForm = new ActiveForm();
-$activeForm->field(class: TextInput::class, name: 'nnn', params: ["style" => "color:RED;display:flex"])
+$activeForm->field(class: TextInput::class, name: 'one', params: ["style" => "color:RED;display:flex"])
->render();
-$activeForm->field(class: TextInput::class, name: 'bbb', params: [])
+$activeForm->field(class: TextInput::class, name: 'two', params: [])
->render();
-$activeForm->field(class: Radio::class, name: 'nameee',params: ["style" => "color:RED;display:flex"])
+$activeForm->field(class: Radio::class, name: 'radio2',params: ["style" => "color:RED;display:flex"])
->setOptions(['1' => 'bbb1', '2' => 'vvv3', 3 => 'ggg3', 4 => 'fgfgfgfg4'])
+ ->setTemplate("{label}{input}
")
->setLabel("bbb222bbb")
->render();
-$activeForm->field(class: Radio::class, name: 'nameee',params: ["style" => "color:RED;display:flex"])
+$activeForm->field(class: Radio::class, name: 'radio2',params: ["style" => "color:RED;display:flex"])
->setLabel("bbbbbb")
->render();
-$activeForm->field(Select::class, 'ddd', ['value' => 2])
+$activeForm->field(Select::class, 'select2', ['value' => 2])
->setOptions(['1' => 'bbb1', '2' => 'vvv3', 3 => 'ggg3', 4 => 'fgfgfgfg4'])
- ->render();
\ No newline at end of file
+ ->render();
+$form->button('button', "Кнопка", ["id" => "button"]);
+$form->endForm();
+
diff --git a/src/ActiveForm.php b/src/ActiveForm.php
index 3caa6a1..7b38d98 100644
--- a/src/ActiveForm.php
+++ b/src/ActiveForm.php
@@ -3,19 +3,43 @@
namespace itguild\forms;
use itguild\forms\builders\SelectBuilder;
+use itguild\forms\builders\TextAreaBuilder;
use itguild\forms\debug\Debug;
use itguild\forms\inputs\BaseInput;
use itguild\forms\inputs\Select;
+use itguild\forms\inputs\TextArea;
+use itguild\forms\templates\Template;
class ActiveForm
{
private BaseInput $fieldObject;
+ /**
+ * @param string $action
+ * @return void
+ */
+ public function beginForm(string $action): void
+ {
+ echo "";
+
+ }
+
public function field($class, string $name, array $params = [])
{
if ($class === Select::class){
$this->fieldObject = SelectBuilder::build($name, $params);
}
+ if ($class === TextArea::class){
+ $this->fieldObject = TextAreaBuilder::build($name, $params);
+ }
else {
$this->fieldObject = new $class($name, $params);
}
@@ -37,6 +61,13 @@ class ActiveForm
return $this;
}
+ public function setTemplate($template): self
+ {
+ $this->fieldObject->setTemplate($template);
+
+ return $this;
+ }
+
public function render()
{
$this->fieldObject->create();
diff --git a/src/Form.php b/src/Form.php
index 285423e..63f5be0 100644
--- a/src/Form.php
+++ b/src/Form.php
@@ -18,7 +18,7 @@ class Form {
*/
public function beginForm(string $action): void
{
- echo "