<?php include __DIR__ . '/../autoload.php'; $form = new Gregwar\Formidable\Form('<form method="post"> <custom source="something" /> </form>'); $form->source('something', 'Hello world!'); echo $form;
<?php include __DIR__ . '/../autoload.php'; $form = new Gregwar\Formidable\Form('<form method="post"> <select name="animal"> <options source="animals" /> </select> </form>'); $form->source('animals', array('cat' => 'Cat', 'dog' => 'Dog')); $form->setValue('animal', 'dog'); echo $form;
<?php session_start(); // required for CSRF include __DIR__ . '/../autoload.php'; include 'person.php'; $form = new Gregwar\Formidable\Form('forms/demoform.html', array()); // Example for setting language to french // $form->setLanguage(new Gregwar\Formidable\Language\French); $form->addConstraint('firstname', function ($value) { if ($value[0] == 'P') { return 'The firstname should not begin with a P!'; } }); $form->source('animals', array('zebra' => 'Zebra', 'bonobo' => 'Bonobo')); $errors = $form->handle(function () use($form) { $data = $form->getValues(); var_dump($data); }); ?> <!DOCTYPE html> <html> <meta charset="utf-8" /> <head> <title>Formidable Demo</title> </head> <body> <h1>Formidable Demo</h1> <?php if ($errors) { ?>