Forms Example PHP >= 5.3

form validation blade html bootstrap foundation emmet

Forms is a utility class that builds web forms in one of the following in built styles

use Luracast/Restler/UI/Forms;
use Luracast/Restler/UI/FormStyles;

Forms::$style = FormStyles::$bootstrap3; // FormStyles::$foundation5;

Where ever you need the generated forms (typically in view templates) just call

echo Forms::get('POST','user/signup');

If you are using twig templates you can use the following instead

{{ form('POST', 'user/signup') }}

Emmet Templates

Forms is using Emmet templates, with which adding more styles is very easy

Emmet Templates is built with a subset of Emmet as in emmet.io extended to serve as a template engine

For example

.form-group>label{$label#}+input.form-control[value=$value# type=$type#

Expands to the following html

<div class="form-group">
    <input class="form-control" value="arul@luracast.com" type="email"/>

When the given data is

    'label' => 'Email',
    'value' => 'arul@luracast.com',
    'type' => 'email'

Typically this data is supplied by the metadata extracted from the php-doc comments of of the api parameters

Users.php and Address.php shows the bare minimum code needed to get create forms.

Check out the resulting form here. Forms We have made it easy to try different styles Also this example serves as an example for our Blade template integration

See bootstrap3.blade.php and foundation5.blade.php

This API Server is made using the following php files/folders

This API Server exposes the following URIs

GET  users        ⇠ Users::index()
POST users/signin ⇠ Users::postSignIn()
POST users/signup ⇠ Users::postSignUp()