<?php if (!$login->submitted()) { echo $login; } elseif (!$login->valid()) { echo "errors: "; var_dump($login->errors()); echo $login; } else { // echo $login->submitted()->getValue(); echo "STORE IN DB values: "; var_dump($login->data()); } echo "<pre><code>" . htmlspecialchars($login) . "</code></pre>"; echo "<hr />"; //echo "<pre><code>" . htmlspecialchars($reg) . "</code></pre>"; if ($reg->valid()) { var_dump($reg->data()); } elseif ($reg->submitted()) { echo "values: "; var_dump($reg->data()); echo "errors: "; var_dump($reg->errors()); echo $reg; } else { var_dump($reg->data()); echo $reg; } ?> </body> </html>
$form->addCheckboxList("test_checkboxList", "hair", array(1 => "Braun", 2 => "Red", 3 => "Blue"))->value(array(3))->rule("required", "Please choose a color"); $form->addText("test_age", "Age")->rule('min', 'minimum 5', 5)->rule('max', 'maximum 2000', 2000); $form->addText("test_age2", "Age range")->rule('range', 'between 5 and 20', 5, 20); $form->addTextarea("test_area", "Description")->rule('min_length', 'minimum 5 symbols', 5)->rule('max_length', 'maximum 2000 symbols', 2000); $form->addTextarea("test_area2", "Descr. range")->rule('length', 'between 5 and 20', 5, 20); $form->addText("fname", "First Name:")->rule('regexp', 'Името трябва да съдържа поне една голяма буква', '/[A-Z]/'); $form->addText("email", "Email:")->rule('email', 'should be valid email')->rule('callback', 'should be \'email@domain.com\'', 'callmeback'); function callmeback($val) { return $val == '*****@*****.**'; } $form->addText("url", "URL:")->rule('url', 'should be a valid url'); $form->addUpload("file", "test")->rule("required"); $form->addSubmit("submit", "Send"); $form->addSubmit("submit2", "Send2"); $tpl = new Ste(); $tpl->load('ste/form.html'); $tpl->set('form', $form->toArray()); $tpl->set('data', var_export($form->data(), true)); $tpl->set('form_code', htmlspecialchars($form)); if ($form->submitted()) { $data = $form->data(); if ($data['test_area'] == '11') { $form->addError('test_area', 'Could not be 11'); } if ($form->valid()) { $tpl->hide('form'); } } header('Content-Type: text/html; charset=utf-8'); echo $tpl->parse();