Example #1
0
 public function testToHTML()
 {
     $args = array('action' => 'http://google.com', 'method' => 'GET', 'id' => 'my_id', 'name' => 'some_name', 'class' => array('form-class'));
     $form = new Form("default", $args);
     $input_args = array('field_type' => 'meta_key', 'format' => 'checkbox', 'values' => array('one', 'two'));
     $input = new Input("myinput", $input_args);
     $form->addInput($input);
     $input_args = array('field_type' => 'search', 'format' => 'text', 'placeholder' => 'Enter keywords...');
     $input = new Input("myinput", $input_args);
     $form->addInput($input);
     $this->assertTrue(is_string($form->toHTML()));
 }
Example #2
0
<?php

require_once 'cap.php';
require_once 'form.php';
$form = new Form('cap_test.php', function () {
    print '<p>Called first</p>';
});
$x_id = $form->text('x', function ($x) {
    return $x * $x;
});
$y_id = $form->text('y', function ($y) {
    return $y * $y;
});
$form->submit('Submit that mutha!', function () use($x_id, $y_id) {
    printf("<p>x squared is %d, y squared is %d.", CAP::$results[$x_id], CAP::$results[$y_id]);
});
echo $form->toHTML();