Example #1
0
<?php

# loader Nix libraries
require_once '../../src/Nix/loader.php';
use Nix\Debugging\Debugger, Nix\Config\Configurator, Nix\Forms\Html, Nix\Forms\Rule, Nix\Forms\Form;
Debugger::init(true);
Debugger::setLogPath(__DIR__ . '/../temp/');
Configurator::write('core.debug', 2);
$form = new Form();
$label_age = Html::el('label', 'Věk')->append(Html::el('small', ' (nepovinné)'));
$form->addText('name', 'Jméno')->addTextarea('aboutMe', 'O mně')->addText('age', $label_age)->addRadio('sex', array('male' => Html::el('img')->src('male.png'), 'female' => Html::el('img')->src('female.png')), 'Pohlaví')->addSelect('city', array('brno', 'Brno', 'ostrava', 'Ostrava', 'praha', 'Praha'))->addPassword('password', 'Heslo')->addPassword('password2', 'Heslo znovu')->addCheckbox('agree', 'Souhlasím')->addSubmit('Register');
$form['name']->addRule(Rule::FILLED);
$form['name']->addRule(Rule::LENGTH, '>5', 'Zadejte délku větší jak 5.');
$form['age']->addCondition(Rule::FILLED)->addRule(Rule::INTEGER)->addRule(Rule::RANGE, array(15, 99));
$form['sex']->addRule(Rule::FILLED);
$form['password']->addRule(Rule::EQUAL, $form['password2'], 'Hesla se musí shodovat');
$form['agree']->addRule(Rule::FILLED, null, 'Musíte souhlasit s podmínkami');
if ($form->isSubmit() && $form->isValid()) {
    echo "<h1>Odeslano:</h1>";
    Debugger::dump($form->data);
    exit;
}
// ======== html render ========
?>

<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="validation/jquery.js"></script>
<script type="text/javascript" src="validation/jquery.validation.js"></script>
<link rel="stylesheet" href="style.css" type="text/css" />
<h1>Nix Forms</h1>
Example #2
0
<?php

# loader Nix libraries
require_once '../../src/Nix/loader.php';
use Nix\Debugging\Debugger, Nix\Forms\Form, Nix\Config\Configurator;
Debugger::init(true);
Debugger::setLogPath(__DIR__ . '/../temp/');
Configurator::write('core.debug', 3);
$form = new Form();
$form->addMultiCheckbox('spotrebice', array('pc' => 'PC', 'dvd' => 'DVD', 'bluray' => 'Blu-Ray'), "Spotřebiče")->addMultiSelect('spotrebice2', array('pc' => 'PC', 'dvd' => 'DVD', 'bluray' => 'Blu-Ray'), "Mé druhé spotřebiče")->addSubmit();
$form->setDefaults(array('spotrebice' => array('pc', 'bluray', 'dvd')));
$form->setDefaults(array('spotrebice2' => array('pc', 'bluray')));
if ($form->isSubmit() && $form->isValid()) {
    echo "<h1>Odeslano:</h1>";
    Debugger::dump($form->data);
}
$form->setRenderer('dl');
// ======== html render ========
?>

<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.validate.js"></script>
<link rel="stylesheet" href="style.css" type="text/css" />

<h1>Multiple Form</h1>

<?php 
echo $form;
Example #3
0
<?php

# loader Nix libraries
require_once '../../src/Nix/loader.php';
use Nix\Debugging\Debugger, Nix\Forms\Form;
Debugger::init(true);
Debugger::setLogPath(__DIR__ . '/../temp/');
$data = array(1, 2, 3, 5, 6, 7);
$form = new Form();
$form->addRadio('radio', array_flip($data))->addSubmit();
//echo $form;
/*
if($form->isSubmit()) {
	Debugger::dump($form->data);
	exit;
}
*/
$html = $form->startTag();
$html .= $form['radio']->label();
$html .= "<table border=1>";
foreach ($data as $i) {
    $html .= "<tr><td>";
    $html .= $form['radio']->getControl($i);
    $html .= "</td><td>Entry {$i}</td></tr>";
}
$html .= $form->addSubmit();
$html .= $form->endTag();
if ($form->isSubmit()) {
    Debugger::dump($form->data);
    exit;
}
Example #4
0
<?php

ob_start();
# loader Nix libraries
require_once '../../src/Nix/loader.php';
use Nix\Debugging\Debugger, Nix\Config\Configurator, Nix\Forms\Form;
Configurator::write('core.debug', 2);
$form = new Form();
$form->addDatepicker('date')->addSubmit();
if ($form->isSubmit()) {
    dump($form->data);
}
?>

<link rel="stylesheet" media="screen" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/cupertino/jquery-ui.min.css" type="text/css" />
<script src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
	google.load("jquery", '1');
	google.load("jqueryui", '1');
	google.setOnLoadCallback(function() {
		$('.calendar').datepicker();
	});
</script>

<?php 
echo $form;
Example #5
0
<?php

# loader Nix libraries
require_once '../../src/Nix/loader.php';
use Nix\Debugging\Debugger, Nix\Forms\Form, Nix\Forms\Rule;
Debugger::init(true);
$form = new Form();
$form->addFile('photo')->addSubmit();
$form['photo']->addRule(Rule::FILLED);
if ($form->isSubmit() && $form->isValid()) {
    echo "<h1>Odeslano:</h1>";
    Debugger::dump($form->data);
    $file = $form->data['photo'];
    if ($file->ok()) {
        unlink('./test.jpeg');
        $file->move("./test.jpeg");
    }
}
// ======== html render ========
?>

<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />

<script type="text/javascript" src="validation/jquery.js"></script>
<script type="text/javascript" src="validation/jquery.validation.js"></script>
<link rel="stylesheet" href="style.css" type="text/css" />
<hr />

<?php 
echo $form->renderer->render();
Example #6
0
<?php

# loader Nix libraries
require_once '../../src/Nix/loader.php';
use Nix\Debugging\Debugger, Nix\Forms\Form;
Debugger::init(true);
$multi = array('desk' => 'Desk', 'pencil' => 'Pencil', 'tv' => 'Televesion', 'pc' => 'Computer');
$form = new Form();
$form->addText('text-field');
$form->addTextarea('textarea');
$form->addMultiCheckbox('multi-checks', $multi);
$form->addMultiSelect('multi-select', $multi);
$form->addSelect('select', $multi);
$form->addSubmit();
$form['select']->setEmptyValue('-- select value --');
if ($form->isSubmit()) {
    Debugger::dump($form->data);
}
echo $form;