Package Data | |
---|---|
Maintainer Username: | encodez |
Maintainer Contact: | muneer@live.it (Muneer Shaheed) |
Package Create Date: | 2015-05-11 |
Package Last Update: | 2015-05-11 |
Language: | PHP |
License: | GPL-3.0 |
Last Refreshed: | 2024-11-26 15:10:31 |
Package Statistics | |
---|---|
Total Downloads: | 18 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 6 |
Total Watchers: | 2 |
Total Forks: | 2 |
Total Open Issues: | 0 |
Simple way to create and validate Phalcon 2 form inpired by the laravel request
The module is in development stage. This is a quick reference. Still the module and documentation has to be improved. I will be adding more notes as I get time
example:
use Encodez\Superform\Form;
class ClientForm extends Form
{
public function __construct()
{
$this->setMethod(Form::METHOD_POST);
parent::__construct();
}
function getFields()
{
return [
'client_name' => [ 'text', 'Client Name', 'class:form-control'],
'email' => ['email', 'EMail', 'class:form-control'],
'building_no' => ['numeric', 'Building No', 'class:form-control'],
'location_name' => [ 'text', 'Location Name', 'class:form-control location'],
];
}
function getRules()
{
return [
'client_name' => 'required|length:5,10',
'building_no' => 'required',
'email' => 'required|email',
'location_name' => 'required',
];
}
/* TODO: Add sanitizers*/
function getFilters()
{
return [
'client_name' => 'trim'
];
}
function getCustomMessages()
{
return [
'client_name:required' => 'Client name is required',
'client_name:length:5,10' => 'Client name must be atleast 5 characters and must not exceed 10',
'client_name:string' => 'Client name contains invalid characters',
];
}
}