Changeset 6608
- Timestamp:
- 12/20/07 13:45:50 (9 months ago)
- Files:
-
- branches/1.1/lib/form/sfForm.class.php (modified) (1 diff)
- branches/1.1/test/unit/form/sfFormTest.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/lib/form/sfForm.class.php
r6326 r6608 173 173 174 174 /** 175 * Returns a cleaned value by field name. 176 * 177 * If the form is not bound, it will return null. 178 * 179 * @param string The name of the value required 180 * @return string The cleaned value 181 */ 182 public function getValue($field) 183 { 184 return $this->isBound ? $this->values[$field] : null; 185 } 186 187 /** 175 188 * Gets the error schema associated with the form. 176 189 * branches/1.1/test/unit/form/sfFormTest.php
r6326 r6608 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test( 58, new lime_output_color());13 $t = new lime_test(60, new lime_output_color()); 14 14 15 15 class FormTest extends sfForm … … 143 143 } 144 144 145 // ->bind() ->isValid() ->getValues() -> isBound() ->getErrorSchema()145 // ->bind() ->isValid() ->getValues() ->getValue() ->isBound() ->getErrorSchema() 146 146 $t->diag('->bind() ->isValid() ->getValues() ->isBound() ->getErrorSchema()'); 147 147 $f = new FormTest(); … … 158 158 $t->ok(!$f->isValid(), '->isValid() returns false if the form is not bound'); 159 159 160 $t->is($f->getValue('first_name'), null, '->getValue() returns null if the form is not bound'); 160 161 $f->bind(array('first_name' => 'Fabien', 'last_name' => 'Potencier')); 161 162 $t->ok($f->isBound(), '->isBound() returns true if the form is bound'); 162 163 $t->is($f->getValues(), array('first_name' => 'Fabien', 'last_name' => 'Potencier'), '->getValues() returns an array of cleaned values if the form is bound'); 163 164 $t->ok($f->isValid(), '->isValid() returns true if the form passes the validation'); 165 $t->is($f->getValue('first_name'), 'Fabien', '->getValue() returns the cleaned value for a field name if the form is bound'); 164 166 165 167 $f->bind(array());