Vegas CMF Guide

Forms library

Basically our Forms works just like default Phalcon version. The main difference is possibility of using arrayed values. It is possible to add forms element with names as follow:


namespace Test\Forms;

use Phalcon\Forms\Element\Text;
use Vegas\Validation\Validator\PresenceOf;

class Test extends \Vegas\Forms\Form
{
    public function initialize()
    {
        $firstName = new Text('name[first]');
        $firstName->addValidator(new PresenceOf());
        $this->add($firstName);

        $lastName = new Text('name[last]');
        $lastName->addValidator(new PresenceOf());
        $this->add($lastName);
    }
}

Possible filled form data received by some endpoint may look like:


[
    'name' => [
        'first' => 'John',
        'last' => 'Doe'
    ]
];