Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/richard1320/php-form-processor
Create webforms on your website in minutes. It has various built-in validation checks and is extendable to allow you to add more features.
https://github.com/richard1320/php-form-processor
composer form form-validation forms php
Last synced: 10 days ago
JSON representation
Create webforms on your website in minutes. It has various built-in validation checks and is extendable to allow you to add more features.
- Host: GitHub
- URL: https://github.com/richard1320/php-form-processor
- Owner: Richard1320
- License: mit
- Created: 2017-04-29T17:22:08.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-10-09T18:26:05.000Z (about 6 years ago)
- Last Synced: 2024-04-19T12:21:10.401Z (7 months ago)
- Topics: composer, form, form-validation, forms, php
- Language: PHP
- Size: 252 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
PHP Form Processor
===================PHP Form Processor allows you to create forms on your website in minutes. It has standard validation checks built in, and you can easily extend the various classes to add your own.
### Features
- A lot of standard validation checks
- Easily extendable classes to create your own custom fields
- Separated template files for easy altering of the form's HTML markup
- Google reCAPTCHA integration## Documentation
The more in-depth features are explained with pages on the [wiki]
# Installation
PHP Form Processor is installed via Composer.
```
composer require pfp/php-form-processor
```After installing it through Composer, you will have to create your field parameters before initializing the form. For a full list of available fields and their parameters, please check out the [list of fields] page on the wiki.
```
$fields = array();$fields['name'] = array(
'label' => 'Name',
'type' => 'text',
'required' => true,
'name' => 'name',
);$fields['email'] = array(
'label' => 'Email',
'type' => 'email',
'required' => true,
'name' => 'email',
);$fields['body'] = array(
'label' => 'Message',
'type' => 'textarea',
'required' => true,
'name' => 'body',
);$form_params = array(
'fields' => $fields,
);$form = new Pfp\PhpFormProcessor\form($form_params);
```### Display the form
After creating a new form object, you can print it out with the `render_form` method.
```
$form->render_form('submissions.php');
```### Submit the form
On the submissions page, you will have to [initialize](#initialize) the form object again with the same parameters. You will also have to pass the form inputted data into the form in order for the validation functions to run.
```
$form->submit_form_data($_POST);
```### Validation
The plugin provides numerous validation checks to all the fields. See the full list of [validation functions] on the wiki.
### Errors
If there are any errors after running the `submit_form_data` method, the errors and the submitted data is saved in the `$_SESSION` superglobal variable.
```
$form->print_errors();
```### Data Retrieval
Data is retrieved with the `get_field_value` method after `submit_form_data`. You will have to pass it the key from the fields array that was set during initialization.
```
$email = $form->get_field_value('email');
```[wiki]:
[list of fields]:
[validation functions]: