public function testMain() { $frm = new SpoonForm('name', 'action'); $frm->addButton('submit', 'submit'); $frm->addCheckbox('agree', true); $frm->addDate('date', time(), 'd/m/Y'); $frm->addDropdown('author', array(1 => 'Davy', 'Tijs', 'Dave'), 1); $frm->addFile('pdf'); $frm->addImage('image'); $frm->addHidden('cant_see_me', 'whoop-tie-doo'); $frm->addMultiCheckbox('hobbies', array(array('label' => 'Swimming', 'value' => 'swimming'))); $frm->addPassword('top_sekret', 'stars-and-stripes'); $frm->addRadiobutton('gender', array(array('label' => 'Male', 'value' => 'male'))); $frm->addTextarea('message', 'big piece of text'); $frm->addText('email', '*****@*****.**'); $frm->addText('now', date('H:i')); }
/** * Client Manager * * Login Page to the system. * @package Client Manager * @author Jin Cong<*****@*****.**> */ define('LOAD_TEMPLATE', true); define('LOAD_HEADER', true); define('IN_LOGIN', true); require 'loader.php'; //create new SpoonForm $frm = new SpoonForm('login'); //create form element $frm->addText('adminname'); $frm->addPassword('adminpw'); $frm->addButton('submit', 'Submit'); if ($frm->isSubmitted()) { if ($frm->getField('adminname')->getValue() == ADMINNAME && $frm->getField('adminpw')->getValue() == ADMINPASSWORD) { $_SESSION['logined'] = true; $_SESSION['adminname'] = $frm->getField('adminname')->getValue(); $_SESSION['adminpw'] = $frm->getField('adminpw')->getValue(); $_SESSION['expired'] = time() + ADMINEXPIRED; header('Location: ' . BASE_URL . '/'); $tpl->assign('tooltip', 'Login Success! System will auto redirect you to front page, <a href="' . BASE_URL . '/index.php">click here if not</a>.'); } else { $tpl->assign('tooltip', 'Admin name or Admin password is not correct!'); } } $frm->parse($tpl); $tpl->display(ROOT_PATH . '/' . TEMPLATE_PATH . '/login.tpl.php');
/** * Adds a single password field. * * @param string $name The name of the field. * @param string[optional] $value The value for the field. * @param int[optional] $maxlength The maximum length for the field. * @param string[optional] $class Class(es) that will be applied on the element. * @param string[optional] $classError Class(es) that will be applied on the element when an error occurs. * @param bool[optional] $HTML Will the field contain HTML? * @return SpoonFormPassword */ public function addPassword($name, $value = null, $maxlength = null, $class = null, $classError = null, $HTML = false) { $name = (string) $name; $value = $value !== null ? (string) $value : null; $maxlength = $maxlength !== null ? (int) $maxlength : null; $class = $class !== null ? (string) $class : 'inputText inputPassword'; $classError = $classError !== null ? (string) $classError : 'inputTextError inputPasswordError'; $HTML = (bool) $HTML; // create and return a password field return parent::addPassword($name, $value, $maxlength, $class, $classError, $HTML); }