Download the PHP package formr/formr without Composer
On this page you can find all versions of the php package formr/formr. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package formr
Short Description Formr is a PHP library which helps you build and validate forms quickly, painlessly, and without all the messy overhead.
License GPL-2.0-only
Informations about the package formr
Formr
Formr is a ridiculously fast and easy PHP form builder, with support for Bootstrap and Bulma right out of the box!
Find docs here: http://formr.github.io
If you find Formr useful, please consider starring the project and/or making a donation. Thank you!
Features
- Create complex forms with server-side processing and validation in seconds
- Built-in support for Bootstrap and Bulma
- Built-in support for reCAPTCHA v3
- Built-in
POST
validation rules, including validating email, regex, comparisons, slugging, and hashing - Instantly make one field required, all fields required, or all but one field required
- Create and validate radio groups and checkbox arrays in seconds
- Upload images: resize, rename, and create thumbnails
- Extensible: easily create and save your own field element wrappers
- Extensible: easily create and save your own dropdown menus
- Extensible: easily create and save your own form & validation sets
- Send plain text and HTML emails
- Generate CSRF tokens and honeypots
- Object-oriented; supports multiple forms per page
- Little helpers to assist in building, layout, testing and debugging
- And a ton of other cool stuff!
Installation
Composer
Run the following command to install Formr with Composer
Then include the autoload.php
file and create a new form object.
Download
Download the .zip file and place the Formr folder in your project, then include the Formr class and create a new form object.
Bootstrap & Bulma Ready
Bootstrap and Bulma form classes are ready to go! Just tell Formr you want to use Bootstrap or Bulma when creating a new form and Formr will take care of the rest.
Basic Example
Simply enter your form labels as a comma delimited string and Formr will build the form, complete with opening and closing tags, a submit button, and email validation - plus all values retained upon POST
. Easy!
Produces the following HTML
Basic Example with More Control
Using the create()
method tells Formr you want control over adding the form tags and submit button yourself. Otherwise it's the same as the Basic Example above.
Produces the following HTML
Pre-Built Forms
Formr has several common forms already baked in, and it's really easy to create and save your own.
Produces the following HTML
Build Forms With Arrays
Produces the following HTML
Build Forms in HTML
You have full control over how you build your forms...
Produces the following HTML
Retrieving POST Values
It's super easy to retrieve your $_POST
values and assign them to variables!
Validation
Formr can easly process and validate your forms
Like the create()
method, we can pass a list of our form labels to the validate()
method, which will get the $_POST
values of our form fields and put them into an array. If your field name is email
, a valid_email
validation rule will be applied automatically!
Basic usage
Let's make sure the form was submitted, then we'll validate and get the value of our email field from the array.
Adding Rules
Let's make sure Name
is a minimum of 2 characters and a maximum of 30 by adding our validation rules wrapped in parentheses.
Fine-Tune Your Validation
Of course you can get more in-depth with your validation, and even add custom error messaging! The following is a basic example, however Formr's validation methods are quite powerful and include, among other things, comparing values between fields and hashing using bcrypt()
Let's get the value of our email
field using the post()
method.
Now let's make sure it's a valid email address by entering the valid_email
validation rule in the third parameter. If there's an error, the text entered into the second parameter will notify the user to correct the Email
field.
We can take that a step further and enter a full custom error message in the second parameter to make our forms even more user-friendly.
Full Example
All versions of formr with dependencies
ext-mbstring Version *