public function setup() { $this->frm = new SpoonForm('datefield'); $this->txtDate = new SpoonFormDate('date', strtotime('Last Monday'), 'd/m/Y'); $this->frm->add($this->txtDate); $_POST['form'] = 'datefield'; }
public function setup() { $this->frm = new SpoonForm('button'); $this->btnSubmit = new SpoonFormButton('submit', 'Submit', 'submit'); $this->btnReset = new SpoonFormButton('reset', 'Reset', 'reset'); $this->btnSpecial = new SpoonFormButton('special', 'Special', 'button'); $this->frm->add($this->btnSubmit, $this->btnReset, $this->btnReset); }
public function setup() { $this->frm = new SpoonForm('radiobutton'); $gender[] = array('label' => 'Female', 'value' => 'F'); $gender[] = array('label' => 'Male', 'value' => 'M'); $this->rbtGender = new SpoonFormRadiobutton('gender', $gender, 'M'); $this->frm->add($this->rbtGender); }
public function testExistsField() { // setup $frm = new SpoonForm('name', 'action'); $frm->addButton('submit', 'submit'); // checks $this->assertTrue($frm->existsField('submit')); $this->assertFalse($frm->existsField('custom_field')); }
public function setup() { $this->frm = new SpoonForm('multicheckbox'); $hobbies[] = array('label' => 'Swimming', 'value' => 10); $hobbies[] = array('label' => 'Cycling', 'value' => 20, 'attributes' => array('rel' => 'bauffman.jpg')); $hobbies[] = array('label' => 'Running', 'value' => 30); $this->chkHobbies = new SpoonFormMultiCheckbox('hobbies', $hobbies, array(10, 20)); $this->frm->add($this->chkHobbies); }
public function setup() { $this->frm = new SpoonForm('radiobutton'); $gender[] = array('label' => 'Female', 'value' => 'F'); $gender[] = array('label' => 'Male', 'value' => 'M'); $this->rbtGender = new SpoonFormRadiobutton('gender', $gender, 'M'); $this->frm->add($this->rbtGender); $numeric = array(array('value' => 1, 'label' => 'One'), array('value' => 1.5, 'label' => 'One And A Half')); $this->rbtNumeric = new SpoonFormRadiobutton('numeric', $numeric, '1'); }
public function setup() { $this->frm = new SpoonForm('filefield'); $this->filePDF = new SpoonFormFile('pdf'); $this->frm->add($this->filePDF); $_FILES['pdf']['name'] = 'My pdf.pdf'; $_FILES['pdf']['type'] = 'application/pdf'; $_FILES['pdf']['tmp_name'] = '/Applications/MAMP/tmp/php/phpDBDfyR'; $_FILES['pdf']['error'] = 0; $_FILES['pdf']['size'] = 86592; }
public function setup() { $this->frm = new SpoonForm('dropdown'); $this->ddmSingle = new SpoonFormDropdown('single', array(1 => 'Davy Hellemans', 'Tys Verkoyen', 'Dave Lens')); $this->ddmMultiple = new SpoonFormDropdown('multiple', array(1 => 'Swimming', 'Running', 'Cycling', 'Boxing', 'Slackin'), null, true); $this->ddmOptGroupSingle = new SpoonFormDropdown('optgroup_single', array('foo', 123 => 'bar', 'foobar' => array('foo', 'baz'))); $this->ddmOptGroupMultiple = new SpoonFormDropdown('optgroup_multiple', array('foo', 123 => 'bar', 'foobar' => array('foo', 'baz')), null, true); $this->ddmDefaultElement = new SpoonFormDropdown('default_element', array(1 => 'Davy Hellemans')); $this->ddmDefaultElement->setDefaultElement('Baz', 1337); $this->frm->add($this->ddmSingle, $this->ddmMultiple, $this->ddmOptGroupSingle, $this->ddmOptGroupMultiple, $this->ddmDefaultElement); }
public function setup() { $this->frm = new SpoonForm('passwordfield'); $this->txtPassword = new SpoonFormPassword('name', 'I am the default value'); $this->frm->add($this->txtPassword); }
<?php /** * 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!'); } }
public function setup() { $this->frm = new SpoonForm('textarea'); $this->txtMessage = new SpoonFormTextarea('message', 'I am the default value'); $this->frm->add($this->txtMessage); }
define('LOAD_TEMPLATE', true); define('LOAD_HEADER', true); require 'loader.php'; if (!isset($_GET['id'])) { header("Location: " . BASE_URL); } if (isset($_GET['delete']) && $_GET['delete'] == 1) { $delete = $mysql->update('profiles', array('status' => 'trash'), 'id = ?', (int) $_GET['id']); $tpl->assign('tooltip', $delete ? 'Profile deleted.' : 'Profile deleting failed.'); } else { $get_user = $mysql->getRecord('SELECT * FROM `profiles` WHERE `id` = \'' . (int) $_GET['id'] . '\' AND `status` != \'trash\''); if (empty($get_user)) { $tpl->assign('tooltip', 'Profile not available'); } else { //create new SpoonForm $frm = new SpoonForm('editProfile'); $frm->addText('file', $get_user['file']); $frm->addText('case', $get_user['case']); $frm->addImage('photo'); if (!empty($get_user['photo'])) { $tpl->assign('photo_path', BASE_URL . '/images.php?thumbnail=1&id=' . (int) $_GET['id']); } $frm->addText('name', $get_user['name']); $frm->addText('ic', $get_user['ic']); $frm->addDropdown('gender', array('' => '', 'male' => 'Male', 'female' => 'Female'), $get_user['gender']); $frm->addText('placeofbirth', $get_user['placeofbirth']); $frm->addText('education', $get_user['education']); $frm->addText('language', $get_user['language']); $frm->addText('race', $get_user['race']); $frm->addText('faith', $get_user['faith']); $frm->addText('maritalstatus', $get_user['maritalstatus']);
<?php /** * Client Manager * * Search engine. * @package Client Manager * @author Jin Cong<*****@*****.**> */ define('LOAD_TEMPLATE', true); define('LOAD_HEADER', true); require 'loader.php'; //create new SpoonForm $frm = new SpoonForm('searchProfile'); //create forms elements $frm->addTexts('file', 'case', 'name', 'ic', 'placeofbirth', 'education', 'language', 'race', 'faith', 'maritalstatus', 'nationality', 'profession', 'epf', 'banker', 'contactno', 'email', 'platesno', 'assets', 'eye', 'hair', 'skin', 'dna', 'company', 'registerno', 'companyno', 'companyemail'); $frm->addTextareas('address', 'family', 'registeraddr', 'businessaddr', 'remarks'); $frm->addDropdown('gender', array('' => '', 'male' => 'Male', 'female' => 'Female')); $frm->addText('height')->setAttribute('placeholder', 'digits only'); $frm->addText('weight')->setAttribute('placeholder', 'digits only'); $frm->addDropdown('blood', array('' => '', 'O+' => 'O+', 'A+' => 'A+', 'B+' => 'B+', 'AB+' => 'AB+', 'O-' => 'O-', 'A-' => 'A-', 'B-' => 'B-', 'AB-' => 'AB-')); $frm->addButton('submit', 'Submit'); if ($frm->isSubmitted()) { //generate query $query = 'SELECT `id`, `photo`, `file`, `case`, `name`, `ic`, `company` FROM `profiles` WHERE `status` != \'trash\' '; $value = $frm->getValues('form', 'submit', '_utf8'); foreach ($value as $key => $value) { if ($value != NULL) { $query .= 'AND '; $query .= '`' . $key . '` LIKE \'%'; $query .= (string) $value;
public function setup() { $this->frm = new SpoonForm('checkbox'); $this->chkAgree = new SpoonFormCheckbox('agree', true); $this->frm->add($this->chkAgree); }
public function setup() { $this->frm = new SpoonForm('timefield'); $this->txtTime = new SpoonFormTime('time', date('H:i')); $this->frm->add($this->txtTime); }
/** * Adds a single time field. * * @param string $name The name of the element. * @param string $value The value inside the element. * @param string $class Class(es) that will be applied on the element. * @param string $classError Class(es) that will be applied on the element when an error occurs. * @return \SpoonFormTime */ public function addTime($name, $value = null, $class = null, $classError = null) { $name = (string) $name; $value = $value !== null ? (string) $value : null; $class = $class !== null ? (string) $class : 'inputText inputTime'; $classError = $classError !== null ? (string) $classError : 'inputTextError inputTimeError'; // create and return a time field return parent::addTime($name, $value, $class, $classError); }
<?php /** * Client Manager * * Front to the system. This file build form to create a profile. * @package Client Manager * @author Jin Cong<*****@*****.**> */ define('LOAD_TEMPLATE', true); define('LOAD_HEADER', true); require 'loader.php'; //create new SpoonForm $frm = new SpoonForm('newProfile'); //create forms elements $frm->addTexts('file', 'case', 'name', 'ic', 'placeofbirth', 'education', 'language', 'race', 'faith', 'maritalstatus', 'nationality', 'profession', 'epf', 'banker', 'contactno', 'email', 'platesno', 'assets', 'eye', 'hair', 'skin', 'dna'); for ($i = 1; $i < 6; $i++) { $frm->addText('company' . $i)->setAttribute("placeholder", "公司名字 company name"); $frm->addText('registerno' . $i)->setAttribute("placeholder", "注册号码 registration number"); $frm->addText('companyno' . $i)->setAttribute("placeholder", "公司号码 Company number"); $frm->addText('companyemail' . $i)->setAttribute("placeholder", "公司电邮 Company email"); $frm->addTextarea('shareholder' . $i)->setAttribute("placeholder", "公司股东 Shareholder"); $frm->addTextarea('registeraddr' . $i)->setAttribute("placeholder", "注册地址 Registered Address"); $frm->addTextarea('businessaddr' . $i)->setAttribute("placeholder", "营业地址Business Address"); } $frm->addTextareas('address', 'family', 'remarks', 'casereport'); $frm->addImage('photo'); $frm->addDropdown('gender', array('' => '', 'male' => 'Male', 'female' => 'Female')); $frm->addText('height')->setAttribute('placeholder', 'digits only'); $frm->addText('weight')->setAttribute('placeholder', 'digits only'); $frm->addDropdown('blood', array('' => '', 'O+' => 'O+', 'A+' => 'A+', 'B+' => 'B+', 'AB+' => 'AB+', 'O-' => 'O-', 'A-' => 'A-', 'B-' => 'B-', 'AB-' => 'AB-'));
public function setup() { $this->frm = new SpoonForm('hiddenfield'); $this->hidHidden = new SpoonFormHidden('hidden', 'I am the default value'); $this->frm->add($this->hidHidden); }
public function setup() { $this->frm = new SpoonForm('textfield'); $this->txtName = new SpoonFormText('name', 'I am the default value'); $this->frm->add($this->txtName); }
/** * Parses the form into the template */ protected function parseForm() { if ($this->step > 1) { $this->frm->parse($this->tpl); } }
/** * Parse the form * * @param SpoonTemplate $tpl The template instance wherein the form will be parsed. */ public function parse(SpoonTemplate $tpl) { // parse the form parent::parse($tpl); // validate the form $this->validate(); // if the form is submitted but there was an error, assign a general error if ($this->isSubmitted() && !$this->isCorrect()) { $tpl->assign('formError', true); } }
/** * Adds a form to this template. * * @param SpoonForm $form The form-instance to add. */ public function addForm(SpoonForm $form) { $this->forms[$form->getName()] = $form; }
/** * Set Company Value from string * * @param SpoonForm $frm * @param string $value */ function setCompanyValue(&$frm, $value) { $values = explode(', ', $value); $count = -1; for ($i = 1; $i < 6; $i++) { $frm->addText('company' . $i, $values[$count += 1])->setAttribute("placeholder", "公司名字 company name"); $frm->addText('registerno' . $i, $values[$count += 1])->setAttribute("placeholder", "注册号码 registration number"); $frm->addText('companyno' . $i, $values[$count += 1])->setAttribute("placeholder", "公司号码 Company number"); $frm->addText('companyemail' . $i, $values[$count += 1])->setAttribute("placeholder", "公司电邮 Company email"); $frm->addTextarea('shareholder' . $i, $values[$count += 1])->setAttribute("placeholder", "公司股东 Shareholder"); $frm->addTextarea('registeraddr' . $i, $values[$count += 1])->setAttribute("placeholder", "注册地址 Registered Address"); $frm->addTextarea('businessaddr' . $i, $values[$count += 1])->setAttribute("placeholder", "营业地址Business Address"); } }