Ejemplo n.º 1
0
 protected function eventEdit($aEvent)
 {
     $oResource = exResourceSet::instance()->fetch($aEvent['get']['r']);
     $oForm = new weeForm('resource', 'edit');
     $oForm->fill($oResource);
     if (isset($aEvent['post'])) {
         $aData = $oForm->filter($aEvent['post']);
         try {
             $oForm->validate($aData);
             $oResource->setFromArray($aData);
             $oResource->update();
             $this->update('replaceContent', '#msg', 'The resource has been successfully edited!');
         } catch (FormValidationException $e) {
             $this->update('replaceContent', '#msg', 'The submitted data is erroneous!');
             $oForm->fillErrors($e);
         }
         $oForm->fill($aData);
         if (array_value($aEvent, 'context') == 'xmlhttprequest') {
             $this->update('replace', 'form', $oForm);
         }
     }
     $this->set('form', $oForm);
 }
Ejemplo n.º 2
0
 protected function defaultEvent($aEvent)
 {
     $oForm = new weeForm('myform', 'update');
     if (!empty($aEvent['post'])) {
         $aData = $oForm->filter($aEvent['post']);
         try {
             $oForm->validate($aData);
             // Validation success: process the form
             doSomething($aData);
         } catch (FormValidationException $e) {
             $oForm->fill($aData);
             $oForm->fillErrors($e);
         }
     }
     $this->set('form', $oForm);
 }
Ejemplo n.º 3
0
Archivo: fill.php Proyecto: extend/wee
<?php

// Initialization
if (!defined('FORM_PATH')) {
    define('FORM_PATH', dirname(__FILE__) . '/form/');
}
// Test
$oForm = new weeForm('mini');
$oForm->fill(array('textbox' => 'Bad'));
$oForm->fill(array('textbox' => 'Good'));
$this->isMatching('/value="Good"/', $oForm->toString(), _WT("The value given to textbox isn't in the generated form."));