https://github.com/yr72dpi/class_form
¤ A php class to generate html form only with php
https://github.com/yr72dpi/class_form
form generator html-form
Last synced: 8 months ago
JSON representation
¤ A php class to generate html form only with php
- Host: GitHub
- URL: https://github.com/yr72dpi/class_form
- Owner: YR72dpi
- Created: 2022-02-16T20:09:12.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-02-17T12:34:41.000Z (over 4 years ago)
- Last Synced: 2025-02-05T14:42:52.879Z (over 1 year ago)
- Topics: form, generator, html-form
- Language: PHP
- Homepage:
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Class Form php
This class was made to create a form with label and some others options easier, with php.
```php
$form = new Form([
"pseudo"=>[
"type" => "text",
"value" => "",
"placeholder" => "Pseudo",
"label" => "Votre pseudo : ",
"required" => true
],
"mdp"=>[
"type" => "password",
"value" => "",
"placeholder" => "Mot de passe",
"label" => "Votre mot de passe :",
"required" => true
],
"text"=>[
"type" => "textarea",
"value" => "",
"placeholder" => "texte",
"label" => "Commentaire"
],
"check"=>[
"type" => "checkbox",
"value" => "1",
"placeholder" => "texte",
"label" => "CGU : ",
"required" => true
],
"music"=>[
"type" => "file",
"label" => "Fichier : ",
"others" => "multiple"
],
""=>[
"type" => "submit",
"value" => "Envoyer",
"placeholder" => "",
"label" => ""
]
]);
$form->getForm();
```
And you can get the form values in an array with
```php
$form->getValue()
```
## setAutoClose() & getCloser()
If you want, you can let the form tag open ("< /form >" not print), write you own code and close it after.
But by default, getForm() auto close the form tag. To prevent it, you have to write :
```php
$form->setAutoClose(false);
```
After, generate your form :
```php
$form = new Form([
// your form param
]);
$form->getForm();
```
Write your own code in the form :
```html
```
To finish, close the form tag:
```php
$form->getCloser();
```