예제 #1
0
파일: Mime.php 프로젝트: robtuley/knotwerk
 function testMimeIsMultipartWhenVisitsFormWithFileUpload()
 {
     $mime = new T_Form_Mime();
     $form = new T_Form_Post('alias', 'label');
     $form->addChild(new T_Form_Text('child', 'label'));
     $form->addChild(new T_Form_Upload('file', 'label'));
     $form->accept($mime);
     $this->assertSame('multipart/form-data', $mime->__toString());
 }
예제 #2
0
// 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()) {
            $date = ' (from ' . date('d-m-Y', $date->getValue()) . ')';
        } else {
            $date = null;
        }
        echo '<p>', $job->search('title')->getValue($f), ', ', $job->search('company')->getValue($f), $date, '</p>';
    }
    $skills = $form->search('skills');
    if ($skills->isPresent()) {
        echo '<p>', $skills->getValue($f), '</p>';
    }
    echo '<p><a href="' . $env->getRequestUrl()->getUrl($f) . '">Try again &rsaquo;</a></p>';
} else {
    // render form
    $error = new T_Form_XhtmlError();
    $render = new Demo_Form_Xhtml();
    $form->accept($error)->accept($render);
    echo $error, $render;
}
require dirname(__FILE__) . '/inc/footer.php';