Esempio n. 1
0
$form = new T_Form_MultiStep('insurance', 'Get a Quote');
// step 1
$step1 = new T_Form_Step('you', 'Contact Details');
$form->addChild($step1);
$fieldset = new T_Form_Fieldset('contact_details', 'Your Details');
$step1->addChild($fieldset);
$fieldset->addChild(new T_Form_Text('name', 'Name'));
$email = new T_Form_Text('email', 'Email');
$email->attachFilter(new T_Validate_Email());
$fieldset->addChild($email);
// step 2
$step2 = new T_Form_Step('your_history', 'Your History');
$form->addChild($step2);
$fieldset = new T_Form_Fieldset('driver_history', 'Driver History');
$step2->addChild($fieldset);
$comment = new T_Form_TextArea('penalty', 'Details of any driving penalties:');
$comment->setOptional();
$fieldset->addChild($comment);
// step 3
$step3 = new T_Form_Step('car', 'Your Car');
$form->addChild($step3);
$fieldset = new T_Form_Fieldset('car_details', 'Your Car');
$step3->addChild($fieldset);
$fieldset->addChild(new T_Form_Text('reg', 'Registration'));
$fieldset->addChild(new T_Form_Text('make', 'Make'));
$fieldset->addChild(new T_Form_Text('model', 'Model'));
$form->setForward($env->getRequestUrl());
// VALIDATE FORM
if ($env->isMethod('POST')) {
    $form->validate($env->input('POST'));
}
Esempio n. 2
0
$form->addChild($fieldset);
$fieldset->addChild(new T_Form_Text('name', 'Name'));
$email = new T_Form_Text('email', 'Email');
$email->attachFilter(new T_Validate_Email());
$fieldset->addChild($email);
$fieldset = new T_Form_Fieldset('prev_jobs', 'Your Previous Jobs');
$form->addChild($fieldset);
$repeated = new T_Form_Repeated('jobs', 'Add Another Job', 1, 6);
$repeated->addChild(new T_Form_Text('title', 'Title'));
$repeated->addChild(new T_Form_Text('company', 'Company'));
$start = new T_Form_Text('start', 'Start Date');
$start->setHelp('Enter date in format dd/mm/yyyy');
$start->setOptional()->attachFilter(new T_Validate_UnixDate('d|m|y'));
$repeated->addChild($start);
$fieldset->addChild($repeated);
$skills = new T_Form_TextArea('skills', 'Additional Info');
$skills->setOptional()->setHelp('Describe any additional career achievements, etc.');
$fieldset->addChild($skills);
$form->setForward($env->getRequestUrl());
// VALIDATE FORM
if ($env->isMethod('POST')) {
    $form->validate($env->input('POST'));
}
// ACTION FORM
if ($form->isPresent() && $form->isValid()) {
    $f = new T_Filter_Xhtml();
    // action (e.g. email, etc.)
    echo '<h2>CV for <a href="mailto:', $form->search('email')->getValue($f), '">', $form->search('name')->getValue($f), '</a></h2>';
    foreach ($form->search('jobs') as $job) {
        $date = $job->search('start');
        if ($date->isPresent()) {
Esempio n. 3
0
 /**
  * Visit a textarea input node.
  *
  * @param T_Form_TextArea $node
  */
 function visitFormTextArea(T_Form_TextArea $node)
 {
     $attributes = $node->getAllAttributes();
     $attributes += array('rows' => 5, 'cols' => 32, 'name' => $node->getFieldname(), 'id' => $this->getNodeId($node));
     $xhtml = $this->createLabel($node);
     // <textarea>
     $xhtml .= $this->preElement($node);
     $xhtml .= $this->indent . '<textarea ';
     foreach ($attributes as $key => $value) {
         $xhtml .= $key . '="' . $this->escape($value) . '"' . EOL . $this->indent . '       ';
     }
     $xhtml = rtrim($xhtml) . ' >' . EOL;
     $xhtml .= $this->escape($node->getDefault());
     $xhtml .= '</textarea>' . EOL;
     $xhtml .= $this->postElement($node);
     $this->addXhtml($xhtml);
 }