PHP code example of seanmorris / form

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

    

seanmorris / form example snippets


$skeleton['_method'] = 'POST';

$skeleton['testField'] = [
  'type' => 'text'
  , '_title' => 'Test Field'
];

$skeleton['submit'] = [
  '_title' => 'Submit'
  , 'type' => 'submit'
];

$form = new \SeanMorris\Form\Form($skeleton);

echo $form->render();


$skeleton['testField'] = [
  'type' => 'text'
  , '_title' => 'Test Field'
  , '_validators' => [
    'SeanMorris\Form\Validator\Regex' => [
      '/.{8,}/' => '%s must be at least 8 characters'
    ]
  ]
];

$form->setValues($_POST);

if($form->validate())
{
  // Values will only contain keys for each of the fields.
  $values = $form->getValues();
}
else
{
  $errors = $form->erorrs();
}