PHP code example of wscore / formmodel

1. Go to this page and download the library: Download wscore/formmodel 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/ */

    

wscore / formmodel example snippets


use WScore\FormModel\FormBuilder;

$builder = FormBuilder::create();
$book = $builder->formModel('book', [
        'label' => 'Book Information',
    ]);

use WScore\FormModel\Type\TextAreaType;
use WScore\FormModel\Type\TextType;

$book
    ->add('title', TextType::class, [
        'label' => 'Book Title',
    ])
    ->add('abstract', TextAreaType::class, [
        'label' => 'Abstracts',
        'attributes' => [
            'style' => 'height: 5em;',
        ]
    ]);

$validation = $book->createValidation($_POST);
if ($validation->isValid()) {
    $data = $validation->getData();
} else {
    $data = []; // just in case...
}

$view = $book->createView();

$validation = $book->createValidation($_POST);
$view = $validation->createView();

cd demo
php -S localhost:8000