Giter VIP home page Giter VIP logo

superform's Introduction

Superform

Simple way to create and validate Phalcon 2 form inpired by the laravel request

Please fork this repository and help improve.

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',
        ];
    }
}

superform's People

Contributors

imuneer avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.