PHP code example of apishka / form

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

    

apishka / form example snippets


class MyForm extends Apishka_Form_FormAbstract
{
    /**
     * Returns form structure
     *
     * @return array
     */

    public function processStructure()
    {
        // This will add signature field to form, to determine when form was posted,
        // don't forger to ka('int_field')
        );
    }
}

$field = Apishka_Form_Field_String::apishka('field_name')
    // By default all fields have unique ID, but if you want to
    // set some specific
    ->setId('some_id')

    // You can mark field as  on value to the end of transformations list
    ->pushTransformation(
        'Transform/Length',
        [
            'min' => 10,
            'max' => 20,
        ]
    )

    // Unshift transformation to transformations list
    ->pushTransformation(
        'Transform/Callback',
        [
            'callback' => function($value)
            {
                return mb_strtolower($value);
            }
        ]
    )
;