コード例 #1
0
 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'));
 }
コード例 #2
0
ファイル: index.php プロジェクト: jincongho/clienthub
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-'));
$frm->addButton('submit', 'Submit');
//if form submitted
if ($frm->isSubmitted()) {
    $frm->getField('name')->isFilled('Please Fill in Client\'s Name.');
    if ($frm->getField('email')->isFilled()) {
        $frm->getField('email')->isEmail('Please provide a valid email address.');
    }
    for ($i = 1; $i < 6; $i++) {
        if ($frm->getField('companyemail' . $i)->isFilled()) {
            $frm->getField('companyemail' . $i)->isEmail('Please provide a valid email address.');
        }
コード例 #3
0
ファイル: form.php プロジェクト: netconstructor/forkcms
 /**
  * Adds a single image field.
  *
  * @return	SpoonFormImage
  * @param	string $name					The name of the element.
  * @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.
  */
 public function addImage($name, $class = null, $classError = null)
 {
     // redefine
     $name = (string) $name;
     $class = $class !== null ? (string) $class : 'inputFile inputImage';
     $classError = $classError !== null ? (string) $classError : 'inputFileError inputImageError';
     // create and return an imagefield
     return parent::addImage($name, $class, $classError);
 }