Changeset 11982
- Timestamp:
- 10/06/08 17:09:28 (5 years ago)
- Files:
-
- branches/1.2/lib/form/sfForm.class.php (modified) (2 diffs)
- branches/1.2/test/unit/form/sfFormTest.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.2/lib/form/sfForm.class.php
r11975 r11982 21 21 * @version SVN: $Id$ 22 22 */ 23 class sfForm implements ArrayAccess 23 class sfForm implements ArrayAccess, Countable 24 24 { 25 25 protected static … … 902 902 903 903 /** 904 * Returns the number of form fields (implements the Countable interface). 905 * 906 * @return integer The number of embedded form fields 907 */ 908 public function count() 909 { 910 return count($this->getFormFieldSchema()); 911 } 912 913 /** 904 914 * Converts uploaded file array to a format following the $_GET and $POST naming convention. 905 915 * branches/1.2/test/unit/form/sfFormTest.php
r11972 r11982 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(1 19, new lime_output_color());13 $t = new lime_test(120, new lime_output_color()); 14 14 15 15 class FormTest extends sfForm … … 175 175 $t->pass('sfForm ArrayAccess implementation throws a LogicException if the form field does not exist'); 176 176 } 177 178 // Countable interface 179 $t->diag('Countable interface'); 180 $f = new FormTest(); 181 $f->setWidgetSchema(new sfWidgetFormSchema(array( 182 'first_name' => new sfWidgetFormInput(array('default' => 'Fabien')), 183 'last_name' => new sfWidgetFormInput(), 184 'image' => new sfWidgetFormInputFile(), 185 ))); 186 $t->is(count($f), 3, 'sfForm implements the Countable interface'); 177 187 178 188 // ->bind() ->isValid() ->hasErrors() ->getValues() ->getValue() ->isBound() ->getErrorSchema()