| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
MintyPHP Forms is a powerful PHP form builder that enables you to create and validate forms without having to write a lot of boilerplate code.
Run the following command to install MintyPHP Forms with Composer.
composer require mintyphp/formsThe package has no dependencies on other packages.
Add the following to alias the most used classes in your PHP file:
use MintyPHP\Form\Elements as E;
use MintyPHP\Form\Validator\Validators as V;Now ensure all classes are (auto)loaded:
require_once 'vendor/autoload.php';And create a simple login form using:
$form = E::form([
E::field(E::text('username'),E::label('Username'),[V::required('Username is required')]),
E::field(E::password('password'),E::label('Password')),
E::field(E::submit('Login')),
]);Now render the form using:
$form->render();And the output is:
<form method="post">
<div>
<label for="username">Username</label>
<input id="username" type="text" name="username" value=""/>
</div>
<div>
<label for="password">Password</label>
<input id="password" type="password" name="password" value=""/>
</div>
<div>
<input type="submit" value="Login"/>
</div>
</form>Easy as that.
MintyPHP Forms has support for the Bulma framework right out of the box. Just tell MintyPHP Forms that you want to use Bulmas style forms using:
E::$style = 'bulma';
// create and render the login form
$form = E::form([
E::field(E::text('username')->required(), E::label('Username')),
E::field(E::password('password'), E::label('Password')),
E::field(E::submit('Login')),
]);
$form->render();And the output will be form in the familiar Bulma style:
<form method="post">
<div class="field">
<label class="label" for="username">Username</label>
<div class="control">
<input id="username" class="input" type="text" name="username" value="" required="required"/>
</div>
</div>
<div class="field">
<label class="label" for="password">Password</label>
<div class="control">
<input id="password" class="input" type="password" name="password" value=""/>
</div>
</div>
<div class="field">
<div class="control">
<input class="button is-primary" type="submit" value="Login"/>
</div>
</div>
</form>In the future we will add support for other frameworks, such as bootstrap 5.
This package has been tested with the MintyPHP backend framework. It can also be used with other frameworks as this package has no dependencies at all.
Although we don't recommend you to use MintyPHP Forms without a backend (or frontend) framework, it is certainly possible, see the full example.
The Form object has the following data methods:
These data methods are typically used on GET:
You can see how these are used in the following full example:
Full example - PHP code - Click here
After filling in a password and clicking "Login" it renders as:
Interested? Read the rest of the documentation.
| Back | FazBrowse Home | New Git URL |