在几秒钟内创建和验证 PHP 表单。
Flick is very similar to Formr, but it's actually easier to use and is far more powerful. I've created a handy migration assistant to help you migrate your forms to Flick.
Flick has most of the same features as Formr, plus a lot more (like stupidly simple multistep forms). It's easier to set up and use, and has a pro package that helps you accomplish pretty much everything else you need (mail, SQL, uploads, auth, client-side validation, etc.), but with the same ease of use you've come to expect.
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!
POST validation rules, including validating email, regex, comparisons, slugging, and hashingRun the following command to install Formr with Composer
composer require formr/formrThen include the autoload.php file and create a new form object.
require_once 'vendor/autoload.php';
$form = new Formr\Formr();Download the .zip file and place the Formr folder in your project, then include the Formr class and create a new form object.
require_once 'Formr/class.formr.php';
$form = new Formr\Formr();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.
$form = new Formr\Formr('bootstrap');$form = new Formr\Formr('bulma');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!
$form = new Formr\Formr('bootstrap');
$form->create_form('Name, Email, Comments|textarea');
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.
$form = new Formr\Formr('bootstrap');
$form->form_open();
$form->create('First name, Last name, Email address, Age|number, Comments|textarea');
$form->submit_button();
$form->form_close();
Formr has several common forms already baked in, and it's really easy to create and save your own.
$form = new Formr\Formr();
$form->fastform('contact');
First name:
Last name:
Email:
Comments:
$data = [
'text' => 'name, Name:',
'email' => 'email, Email:',
'checkbox' => 'agree, I Agree',
];
$form = new Formr\Formr('bootstrap');
$form->fastform($data);
You have full control over how you build your forms...
It's super easy to retrieve your $_POST values and assign them to variables!
$name = $form->post('name');
$email = $form->post('email');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!
$form->validate('Name, Email, Comments');Let's make sure the form was submitted, then we'll validate and get the value of our email field from the array.
if($form->submitted()) {
$data = $form->validate('Name, Email, Comments');
$email = $data['email'];
}Let's make sure Name is a minimum of 2 characters and a maximum of 30 by adding our validation rules wrapped in parentheses.
$form->validate('Name(min[2]|max[30]), Email, Comments');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.
$email = $form->post('email');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.
$email = $form->post('email','Email','valid_email');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.
$email = $form->post('email','Email|Please enter a valid email address','valid_email');…暂无开放 Issues,或尚未同步最近议题。