Configure the edit form

Validation

You can add validation to the form by passing extra parameters to the addColumn options parameter as follows. Simply set required to true to enforce required. You can also pass separate validator functions as a closure or a callable.

<?php

$sqlPage = new MySQLTablePage ("Name", "user", "password", "database_name");
$sqlPage->setName("Page Title")
        ->setTableName ("table_name")  // Set the table name
        ->setPrimaryColumn ("id")
        ->addColumn ("username",  "Nickname", array(
            "required" => true
            ))
        ->addColumn ("password",  "Password", array(
            "validator" => function($value){return (strlen($value) >= 8);},
            "required" => true
            ))
        ->addColumn ("age", "Age")
        ->addColumn ("color", "Color")
        ->setSummaryColumns(array("username", "age"));

Built by Anirudh Sanjeev. CrudKit is distributed under the MIT/X11 License.