百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
F

formr

> 数据库
开源

在几秒钟内创建和验证 PHP 表单。

381 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

在几秒钟内创建和验证 PHP 表单。

Formr

Latest Version on Packagist Total Downloads


Formr is discontinued. Please use Flick

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.

  • Flick website
  • Flick repo

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, Bulma, Tailwind and Uikit
  • 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

bash
composer require formr/formr

Then include the autoload.php file and create a new form object.

php
require_once 'vendor/autoload.php';
$form = new Formr\Formr();

Download

Download the .zip file and place the Formr folder in your project, then include the Formr class and create a new form object.

php
require_once 'Formr/class.formr.php';
$form = new Formr\Formr();

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.

php
$form = new Formr\Formr('bootstrap');
php
$form = new Formr\Formr('bulma');

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!

php
$form = new Formr\Formr('bootstrap');
$form->create_form('Name, Email, Comments|textarea');

Produces the following HTML

xml

    

    

    

    

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.

php
$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();

Produces the following HTML

xml

    

    

    

    

    

    

Pre-Built Forms

Formr has several common forms already baked in, and it's really easy to create and save your own.

php
$form = new Formr\Formr();
$form->fastform('contact');

Produces the following HTML

xml

    
        
            First name:
        
        

        
            Last name:
        
        

        
            Email:
        
        

        
            Comments:
        
        

        
    

Build Forms With Arrays

php
$data = [
    'text' => 'name, Name:',
    'email' => 'email, Email:',
    'checkbox' => 'agree, I Agree',
];

$form = new Formr\Formr('bootstrap');
$form->fastform($data);

Produces the following HTML

xml

    
        

        

        

        

    

Build Forms in HTML

You have full control over how you build your forms...

xml

Produces the following HTML

xml

Retrieving POST Values

It's super easy to retrieve your $_POST values and assign them to variables!

php
$name = $form->post('name');
$email = $form->post('email');

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

php
$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.

php
if($form->submitted()) {
    $data = $form->validate('Name, Email, Comments');
    $email = $data['email'];
}

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.

php
$form->validate('Name(min[2]|max[30]), Email, Comments');

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.

php
$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.

php
$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.

php
$email = $form->post('email','Email|Please enter a valid email address','valid_email');

Full Example

…

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

PHPbootstrapbulmaformform-builder

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类数据库
定价开源

> 相关工具

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库