{"id":14988561,"url":"https://github.com/formr/formr","last_synced_at":"2025-05-14T20:09:43.186Z","repository":{"id":30384481,"uuid":"33937128","full_name":"formr/formr","owner":"formr","description":"Create and Validate PHP Forms in Seconds.","archived":false,"fork":false,"pushed_at":"2025-03-16T22:41:51.000Z","size":471,"stargazers_count":370,"open_issues_count":0,"forks_count":76,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-05-10T05:21:06.103Z","etag":null,"topics":["bootstrap","bulma","form","form-builder","form-class","form-library","form-validation","forms","honeypot","open-source","php-form","php-form-builder","php-validation","php-validator","recaptcha","validation"],"latest_commit_sha":null,"homepage":"https://formr.github.io","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/formr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["timgavin"]}},"created_at":"2015-04-14T14:36:30.000Z","updated_at":"2025-05-08T09:08:07.000Z","dependencies_parsed_at":"2023-02-19T01:46:04.844Z","dependency_job_id":"eb7fe055-615e-4ce3-810d-713329d3528f","html_url":"https://github.com/formr/formr","commit_stats":{"total_commits":101,"total_committers":11,"mean_commits":9.181818181818182,"dds":"0.13861386138613863","last_synced_commit":"ba51f8a2ce2db80b4bfc45d80a3f153a323a75ae"},"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/formr%2Fformr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/formr%2Fformr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/formr%2Fformr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/formr%2Fformr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/formr","download_url":"https://codeload.github.com/formr/formr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254219374,"owners_count":22034397,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bootstrap","bulma","form","form-builder","form-class","form-library","form-validation","forms","honeypot","open-source","php-form","php-form-builder","php-validation","php-validator","recaptcha","validation"],"created_at":"2024-09-24T14:16:56.411Z","updated_at":"2025-05-14T20:09:43.161Z","avatar_url":"https://github.com/formr.png","language":"PHP","readme":"# Formr\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Total Downloads][ico-downloads]][link-downloads]\n\nFormr is a ridiculously fast and easy PHP form builder, with support for Bootstrap and Bulma right out of the box!\n\nFind docs here: [http://formr.github.io](http://formr.github.io)\n\nIf you find Formr useful, please consider starring the project and/or making a [donation](https://paypal.me/timgavin). Thank you!\n\n## Features\n\n- Create complex forms with server-side processing and validation in seconds\n- Built-in support for Bootstrap, Bulma, Tailwind and Uikit\n- Built-in support for reCAPTCHA v3\n- Built-in `POST` validation rules, including validating email, regex, comparisons, slugging, and hashing\n- Instantly make one field required, all fields required, or all but one field required\n- Create and validate radio groups and checkbox arrays in seconds\n- Upload images: resize, rename, and create thumbnails\n- Extensible: easily create and save your own field element wrappers\n- Extensible: easily create and save your own dropdown menus\n- Extensible: easily create and save your own form \u0026 validation sets\n- Send plain text and HTML emails\n- Generate CSRF tokens and honeypots\n- Object-oriented; supports multiple forms per page\n- Little helpers to assist in building, layout, testing and debugging\n- And a ton of other cool stuff!\n\n## Installation\n\n#### Composer\nRun the following command to install Formr with Composer\n\n```bash\ncomposer require formr/formr\n```\n\nThen include the `autoload.php` file and create a new form object.\n\n```php\nrequire_once 'vendor/autoload.php';\n$form = new Formr\\Formr();\n```\n\n#### Download\n\nDownload the .zip file and place the Formr folder in your project, then include the Formr class and create a new form object.\n\n```php\nrequire_once 'Formr/class.formr.php';\n$form = new Formr\\Formr();\n```\n\n## Bootstrap \u0026 Bulma Ready\n\nBootstrap 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.\n\n```php\n$form = new Formr\\Formr('bootstrap');\n```\n\n```php\n$form = new Formr\\Formr('bulma');\n```\n\n## Basic Example\n\nSimply 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!\n\n```php\n$form = new Formr\\Formr('bootstrap');\n$form-\u003ecreate_form('Name, Email, Comments|textarea');\n```\n\n### Produces the following HTML\n\n```html\n\u003cform action=\"/index.php\" method=\"post\" accept-charset=\"utf-8\"\u003e\n\n    \u003cdiv id=\"_name\" class=\"form-group\"\u003e\n        \u003clabel class=\"control-label\" for=\"name\"\u003e\n            Name\n        \u003c/label\u003e\n        \u003cinput type=\"text\" name=\"name\" id=\"name\" class=\"form-control\"\u003e\n    \u003c/div\u003e\n\n    \u003cdiv id=\"_email\" class=\"form-group\"\u003e\n        \u003clabel class=\"control-label\" for=\"email\"\u003e\n            Email\n        \u003c/label\u003e\n        \u003cinput type=\"email\" name=\"email\" id=\"email\" class=\"form-control\"\u003e\n    \u003c/div\u003e\n\n    \u003cdiv id=\"_comments\" class=\"form-group\"\u003e\n        \u003clabel class=\"control-label\" for=\"comments\"\u003e\n            Comments\n        \u003c/label\u003e\n        \u003ctextarea name=\"comments\" id=\"comments\" class=\"form-control\"\u003e\u003c/textarea\u003e\n    \u003c/div\u003e\n\n    \u003cdiv id=\"_button\" class=\"form-group\"\u003e\n        \u003clabel class=\"sr-only\" for=\"button\"\u003e\u003c/label\u003e\n        \u003cbutton type=\"submit\" name=\"button\" id=\"button\" class=\"btn btn-primary\"\u003eSubmit\u003c/button\u003e\n    \u003c/div\u003e\n\n\u003c/form\u003e\n```\n\n## Basic Example with More Control\n\nUsing 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.\n\n```php\n$form = new Formr\\Formr('bootstrap');\n$form-\u003eform_open();\n$form-\u003ecreate('First name, Last name, Email address, Age|number, Comments|textarea');\n$form-\u003esubmit_button();\n$form-\u003eform_close();\n```\n\n#### Produces the following HTML\n\n```html\n\u003cform action=\"/index.php\" method=\"post\" accept-charset=\"utf-8\"\u003e\n    \u003cdiv id=\"_first_name\" class=\"form-group\"\u003e\n        \u003clabel class=\"control-label\" for=\"first_name\"\u003e\n            First name\n        \u003c/label\u003e\n        \u003cinput type=\"text\" name=\"first_name\" id=\"first_name\" class=\"form-control\"\u003e\n    \u003c/div\u003e\n    \u003cdiv id=\"_last_name\" class=\"form-group\"\u003e\n        \u003clabel class=\"control-label\" for=\"last_name\"\u003e\n            Last name\n        \u003c/label\u003e\n        \u003cinput type=\"text\" name=\"last_name\" id=\"last_name\" class=\"form-control\"\u003e\n    \u003c/div\u003e\n    \u003cdiv id=\"_email_address\" class=\"form-group\"\u003e\n        \u003clabel class=\"control-label\" for=\"email_address\"\u003e\n            Email address\n        \u003c/label\u003e\n        \u003cinput type=\"email\" name=\"email_address\" id=\"email_address\" class=\"form-control\"\u003e\n    \u003c/div\u003e\n    \u003cdiv id=\"_age\" class=\"form-group\"\u003e\n        \u003clabel class=\"control-label\" for=\"age\"\u003e\n            Age\n        \u003c/label\u003e\n        \u003cinput type=\"number\" name=\"age\" id=\"age\" class=\"form-control\"\u003e\n    \u003c/div\u003e\n    \u003cdiv id=\"_comments\" class=\"form-group\"\u003e\n        \u003clabel class=\"control-label\" for=\"comments\"\u003e\n            Comments\n        \u003c/label\u003e\n        \u003ctextarea name=\"comments\" id=\"comments\" class=\"form-control\"\u003e\u003c/textarea\u003e\n    \u003c/div\u003e\n    \u003cdiv id=\"_submit\" class=\"form-group\"\u003e\n        \u003clabel class=\"sr-only\" for=\"submit\"\u003e\u003c/label\u003e\n        \u003cbutton type=\"submit\" name=\"submit\" id=\"submit\" class=\"btn btn-primary\"\u003eSubmit\u003c/button\u003e\n    \u003c/div\u003e\n\u003c/form\u003e\n```\n\n## Pre-Built Forms\n\nFormr has several common forms already baked in, and it's really easy to [create and save your own](https://github.com/formr/extend).\n\n```php\n$form = new Formr\\Formr();\n$form-\u003efastform('contact');\n```\n\n#### Produces the following HTML\n\n```html\n\u003cform action=\"/index.php\" method=\"post\" accept-charset=\"utf-8\"\u003e\n    \u003cfieldset\u003e\n        \u003clabel for=\"fname\"\u003e\n            First name:\n        \u003c/label\u003e\n        \u003cinput type=\"text\" name=\"fname\" id=\"fname\" class=\"input\"\u003e\n\n        \u003clabel for=\"lname\"\u003e\n            Last name:\n        \u003c/label\u003e\n        \u003cinput type=\"text\" name=\"lname\" id=\"lname\" class=\"input\"\u003e\n\n        \u003clabel for=\"email\"\u003e\n            Email:\n        \u003c/label\u003e\n        \u003cinput type=\"email\" name=\"email\" id=\"email\" class=\"input\"\u003e\n\n        \u003clabel for=\"comments\"\u003e\n            Comments:\n        \u003c/label\u003e\n        \u003ctextarea name=\"comments\" id=\"comments\" class=\"input\" \u003e\u003c/textarea\u003e\n\n        \u003cinput type=\"submit\" name=\"submit\" value=\"Submit\" id=\"submit\"\u003e\n    \u003c/fieldset\u003e\n\u003c/form\u003e\n```\n\n## Build Forms With Arrays\n\n```php\n$data = [\n    'text' =\u003e 'name, Name:',\n    'email' =\u003e 'email, Email:',\n    'checkbox' =\u003e 'agree, I Agree',\n];\n\n$form = new Formr\\Formr('bootstrap');\n$form-\u003efastform($data);\n```\n\n#### Produces the following HTML\n\n```html\n\u003cform action=\"/index.php\" method=\"post\" accept-charset=\"utf-8\"\u003e\n    \u003cfieldset\u003e\n        \u003cdiv id=\"_name\" class=\"form-group\"\u003e\n            \u003clabel class=\"control-label\" for=\"name\"\u003e\n                Name:\n            \u003c/label\u003e\n            \u003cinput type=\"text\" name=\"name\" class=\"form-control\" id=\"name\"\u003e\n        \u003c/div\u003e\n\n        \u003cdiv id=\"_email\" class=\"form-group\"\u003e\n            \u003clabel class=\"control-label\" for=\"email\"\u003e\n                Email:\n            \u003c/label\u003e\n            \u003cinput type=\"email\" name=\"email\" class=\"form-control\" id=\"email\"\u003e\n        \u003c/div\u003e\n\n        \u003cdiv id=\"_agree\" class=\"checkbox\"\u003e\n            \u003clabel for=\"agree\"\u003e\n                \u003cinput type=\"checkbox\" name=\"agree\" value=\"agree\" id=\"agree\"\u003e I Agree\n            \u003c/label\u003e\n        \u003c/div\u003e\n\n        \u003cdiv id=\"_submit\" class=\"form-group\"\u003e\n            \u003clabel class=\"sr-only\" for=\"submit\"\u003e\u003c/label\u003e\n            \u003cinput type=\"submit\" name=\"submit\" value=\"Submit\" id=\"submit\" class=\"btn\"\u003e\n        \u003c/div\u003e\n    \u003c/fieldset\u003e\n\u003c/form\u003e\n```\n\n## Build Forms in HTML\n\nYou have full control over how you build your forms...\n\n```html\n\u003cdiv class=\"my-wrapper-class\"\u003e\n    \u003c?php $form-\u003etext('name', 'Name'); ?\u003e\n\u003c/div\u003e\n\n\u003cdiv class=\"my-wrapper-class\"\u003e\n    \u003c?php $form-\u003eemail('email', 'Email address', 'john@example.com', 'emailID', 'placeholder=\"email@domain.com\"'); ?\u003e\n\u003c/div\u003e\n\n\u003cdiv class=\"my-wrapper-class\"\u003e\n    \u003cinput type=\"text\" name=\"address\" value=\"\u003c?php $form-\u003evalue('address') ?\u003e\"\u003e\n\u003c/div\u003e\n```\n\n#### Produces the following HTML\n\n```html\n\u003cdiv class=\"my-wrapper-class\"\u003e\n    \u003clabel for=\"name\"\u003e\n        Name\n    \u003c/label\u003e\n    \u003cinput type=\"text\" name=\"name\" id=\"name\"\u003e\n\u003c/div\u003e\n\n\u003cdiv class=\"my-wrapper-class\"\u003e\n    \u003clabel for=\"emailID\"\u003e\n        Email address\n    \u003c/label\u003e\n    \u003cinput type=\"email\" name=\"email\" id=\"emailID\" value=\"john@example.com\" placeholder=\"email@domain.com\"\u003e\n\u003c/div\u003e\n```\n\n## Retrieving POST Values\n\nIt's super easy to retrieve your `$_POST` values and assign them to variables!\n\n```php\n$name = $form-\u003epost('name');\n$email = $form-\u003epost('email');\n```\n\n## Validation\n\n#### Formr can easly process and validate your forms\n\nLike 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!\n\n#### Basic usage\n\n```php\n$form-\u003evalidate('Name, Email, Comments');\n```\n\nLet's make sure the form was submitted, then we'll validate and get the value of our email field from the array.\n\n```php\nif($form-\u003esubmitted()) {\n    $data = $form-\u003evalidate('Name, Email, Comments');\n    $email = $data['email'];\n}\n```\n\n#### Adding Rules\n\nLet's make sure `Name` is a minimum of 2 characters and a maximum of 30 by adding our validation rules wrapped in parentheses.\n\n```php\n$form-\u003evalidate('Name(min[2]|max[30]), Email, Comments');\n```\n\n## Fine-Tune Your Validation\n\nOf 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()`\n\nLet's get the value of our `email` field using the `post()` method.\n\n```php\n$email = $form-\u003epost('email');\n```\n\nNow 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.\n\n```php\n$email = $form-\u003epost('email','Email','valid_email');\n```\n\nWe 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.\n\n```php\n$email = $form-\u003epost('email','Email|Please enter a valid email address','valid_email');\n```\n\n## Full Example\n\n```php\n\u003c?php\n// include the Formr class\nrequire_once 'Formr/class.formr.php';\n\n// create our form object and use Bootstrap 4 as our form wrapper\n$form = new Formr\\Formr('bootstrap');\n\n// make all fields required\n$form-\u003erequired = '*';\n\n// check if the form has been submitted\nif($form-\u003esubmitted())\n{\n    // make sure our Message field has at least 10 characters\n    $form-\u003evalidate('Message(min[10])');\n\n    // let's email the form\n    $to = 'me@email.com';\n    $from = 'donotreply@domain.com';\n    $subject = 'Contact Form Submission';\n\n    // this processes our form, cleans the input, and sends it as an HTML email\n    if($form-\u003esend_email($to, $subject, 'POST', $from, 'HTML'))\n    {\n        // email sent; print a thank you message\n        $form-\u003esuccess_message('Thank you for filling out our form!');\n    }\n}\n?\u003e\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n    \u003cmeta charset=\"UTF-8\" /\u003e\n    \u003ctitle\u003eFormr\u003c/title\u003e\n    \u003clink rel=\"stylesheet\" href=\"https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css\" crossorigin=\"anonymous\"\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n    \u003cdiv class=\"container\"\u003e\n        \u003c?php\n            // print messages, formatted using Bootstrap alerts\n            $form-\u003emessages();\n\n            // create the form\n            $form-\u003ecreate_form('First name, Last name, Email address, Message|textarea');\n        ?\u003e\n    \u003c/div\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n[ico-version]: https://img.shields.io/packagist/v/formr/formr.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/formr/formr.svg?style=flat-square\n\n[link-packagist]: https://packagist.org/packages/formr/formr\n[link-downloads]: https://packagist.org/packages/formr/formr\n[link-author]: https://github.com/timgavin\n","funding_links":["https://github.com/sponsors/timgavin","https://paypal.me/timgavin"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fformr%2Fformr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fformr%2Fformr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fformr%2Fformr/lists"}