PHP code example of mindplay / kissform

1. Go to this page and download the library: Download mindplay/kissform library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mindplay / kissform example snippets


class UserForm
{
    /** @var TextField */
    public $first_name;

    /** @var TextField */
    public $last_name;

    public function __construct()
    {
        $this->first_name = new TextField('first_name');
        $this->first_name->setLabel('First Name');
        $this->first_name->setRequired();

        $this->last_name = new TextField('last_name');
        $this->last_name->setLabel('Last Name');
        $this->last_name->setRequired();
    }
}

$form = new InputRenderer(@$_POST['user'], 'user');

$t = new UserForm();


$model = InputModel::create($_POST['user']);

$validator = new InputValidation($model);

$validator->check([$t->first_name, $t->last_name]);

if ($model->isValid()) {
    // no errors!
} else {
    var_dump($model->errors); // returns e.g. array("first_name" => "First Name is 

$first_name = $form->first_name->getValue($model);
$last_name = $form->last_name->getValue($model);

$form->first_name->setValue($model, "Rasmus");
$form->last_name->setValue($model, "Schultz");