Changeset 17587
- Timestamp:
- 04/24/09 20:41:19 (3 years ago)
- Files:
-
- branches/1.1/lib/form/sfFormFieldSchema.class.php (modified) (1 diff)
- branches/1.1/lib/widget/sfWidgetFormSchema.class.php (modified) (1 diff)
- branches/1.1/test/unit/form/sfFormTest.php (modified) (2 diffs)
- branches/1.2/lib/form/sfFormFieldSchema.class.php (modified) (1 diff)
- branches/1.2/lib/widget/sfWidgetFormSchema.class.php (modified) (1 diff)
- branches/1.2/test/unit/form/sfFormTest.php (modified) (2 diffs)
- branches/1.3/lib/form/sfFormFieldSchema.class.php (modified) (1 diff)
- branches/1.3/lib/widget/sfWidgetFormSchema.class.php (modified) (1 diff)
- branches/1.3/test/unit/form/sfFormTest.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/lib/form/sfFormFieldSchema.class.php
r9045 r17587 68 68 } 69 69 70 $ class = $widget instanceof sfWidgetFormSchema ? 'sfFormFieldSchema' : 'sfFormField';70 $error = isset($this->error[$name]) ? $this->error[$name] : null; 71 71 72 $this->fields[$name] = new $class($widget, $this, $name, isset($this->value[$name]) ? $this->value[$name] : null, isset($this->error[$name]) ? $this->error[$name] : null); 72 if ($widget instanceof sfWidgetFormSchema) 73 { 74 $class = 'sfFormFieldSchema'; 75 76 if ($error && !$error instanceof sfValidatorErrorSchema) 77 { 78 $error = new sfValidatorErrorSchema($error->getValidator(), array($error)); 79 } 80 } 81 else 82 { 83 $class = 'sfFormField'; 84 } 85 86 $this->fields[$name] = new $class($widget, $this, $name, isset($this->value[$name]) ? $this->value[$name] : null, $error); 73 87 } 74 88 branches/1.1/lib/widget/sfWidgetFormSchema.class.php
r16227 r17587 327 327 { 328 328 throw new InvalidArgumentException(sprintf('The field named "%s" does not exist.', $name)); 329 } 330 331 if ($widget instanceof sfWidgetFormSchema && $errors && !$errors instanceof sfValidatorErrorSchema) 332 { 333 $errors = new sfValidatorErrorSchema($errors->getValidator(), array($errors)); 329 334 } 330 335 branches/1.1/test/unit/form/sfFormTest.php
r17023 r17587 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(10 3, new lime_output_color());13 $t = new lime_test(105, new lime_output_color()); 14 14 15 15 class FormTest extends sfForm … … 382 382 383 383 $t->is($w['authors'][0]->generateName('first_name'), 'article[authors][0][first_name]', '->embedFormForEach() changes the name format to reflect the embedding'); 384 385 // bind too many values for embedded forms 386 $t->diag('bind too many values for embedded forms'); 387 $list = new FormTest(); 388 $list->setWidgets(array('title' => new sfWidgetFormInput())); 389 $list->setValidators(array('title' => new sfValidatorString())); 390 $list->embedFormForEach('items', clone $list, 2); 391 $list->bind(array( 392 'title' => 'list title', 393 'items' => array( 394 array('title' => 'item 1'), 395 array('title' => 'item 2'), 396 array('title' => 'extra item'), 397 ), 398 )); 399 400 $t->isa_ok($list['items'][0]->getError(), 'sfValidatorErrorSchema', '"sfFormFieldSchema" is given an error schema when an extra embedded form is bound'); 401 402 // does this trigger a fatal error? 403 $list['items']->render(); 404 $t->pass('"sfFormFieldSchema" renders when an extra embedded form is bound'); 384 405 385 406 // ::convertFileInformation() branches/1.2/lib/form/sfFormFieldSchema.class.php
r9045 r17587 68 68 } 69 69 70 $ class = $widget instanceof sfWidgetFormSchema ? 'sfFormFieldSchema' : 'sfFormField';70 $error = isset($this->error[$name]) ? $this->error[$name] : null; 71 71 72 $this->fields[$name] = new $class($widget, $this, $name, isset($this->value[$name]) ? $this->value[$name] : null, isset($this->error[$name]) ? $this->error[$name] : null); 72 if ($widget instanceof sfWidgetFormSchema) 73 { 74 $class = 'sfFormFieldSchema'; 75 76 if ($error && !$error instanceof sfValidatorErrorSchema) 77 { 78 $error = new sfValidatorErrorSchema($error->getValidator(), array($error)); 79 } 80 } 81 else 82 { 83 $class = 'sfFormField'; 84 } 85 86 $this->fields[$name] = new $class($widget, $this, $name, isset($this->value[$name]) ? $this->value[$name] : null, $error); 73 87 } 74 88 branches/1.2/lib/widget/sfWidgetFormSchema.class.php
r16733 r17587 455 455 { 456 456 throw new InvalidArgumentException(sprintf('The field named "%s" does not exist.', $name)); 457 } 458 459 if ($widget instanceof sfWidgetFormSchema && $errors && !$errors instanceof sfValidatorErrorSchema) 460 { 461 $errors = new sfValidatorErrorSchema($errors->getValidator(), array($errors)); 457 462 } 458 463 branches/1.2/test/unit/form/sfFormTest.php
r17023 r17587 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(1 38, new lime_output_color());13 $t = new lime_test(140, new lime_output_color()); 14 14 15 15 class FormTest extends sfForm … … 505 505 506 506 $t->is($w['authors'][0]->generateName('first_name'), 'article[authors][0][first_name]', '->embedFormForEach() changes the name format to reflect the embedding'); 507 508 // bind too many values for embedded forms 509 $t->diag('bind too many values for embedded forms'); 510 $list = new FormTest(); 511 $list->setWidgets(array('title' => new sfWidgetFormInput())); 512 $list->setValidators(array('title' => new sfValidatorString())); 513 $list->embedFormForEach('items', clone $list, 2); 514 $list->bind(array( 515 'title' => 'list title', 516 'items' => array( 517 array('title' => 'item 1'), 518 array('title' => 'item 2'), 519 array('title' => 'extra item'), 520 ), 521 )); 522 523 $t->isa_ok($list['items'][0]->getError(), 'sfValidatorErrorSchema', '"sfFormFieldSchema" is given an error schema when an extra embedded form is bound'); 524 525 // does this trigger a fatal error? 526 $list['items']->render(); 527 $t->pass('"sfFormFieldSchema" renders when an extra embedded form is bound'); 507 528 508 529 // ->getEmbeddedForms() branches/1.3/lib/form/sfFormFieldSchema.class.php
r9045 r17587 68 68 } 69 69 70 $ class = $widget instanceof sfWidgetFormSchema ? 'sfFormFieldSchema' : 'sfFormField';70 $error = isset($this->error[$name]) ? $this->error[$name] : null; 71 71 72 $this->fields[$name] = new $class($widget, $this, $name, isset($this->value[$name]) ? $this->value[$name] : null, isset($this->error[$name]) ? $this->error[$name] : null); 72 if ($widget instanceof sfWidgetFormSchema) 73 { 74 $class = 'sfFormFieldSchema'; 75 76 if ($error && !$error instanceof sfValidatorErrorSchema) 77 { 78 $error = new sfValidatorErrorSchema($error->getValidator(), array($error)); 79 } 80 } 81 else 82 { 83 $class = 'sfFormField'; 84 } 85 86 $this->fields[$name] = new $class($widget, $this, $name, isset($this->value[$name]) ? $this->value[$name] : null, $error); 73 87 } 74 88 branches/1.3/lib/widget/sfWidgetFormSchema.class.php
r16733 r17587 455 455 { 456 456 throw new InvalidArgumentException(sprintf('The field named "%s" does not exist.', $name)); 457 } 458 459 if ($widget instanceof sfWidgetFormSchema && $errors && !$errors instanceof sfValidatorErrorSchema) 460 { 461 $errors = new sfValidatorErrorSchema($errors->getValidator(), array($errors)); 457 462 } 458 463 branches/1.3/test/unit/form/sfFormTest.php
r17023 r17587 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(1 38, new lime_output_color());13 $t = new lime_test(140, new lime_output_color()); 14 14 15 15 class FormTest extends sfForm … … 505 505 506 506 $t->is($w['authors'][0]->generateName('first_name'), 'article[authors][0][first_name]', '->embedFormForEach() changes the name format to reflect the embedding'); 507 508 // bind too many values for embedded forms 509 $t->diag('bind too many values for embedded forms'); 510 $list = new FormTest(); 511 $list->setWidgets(array('title' => new sfWidgetFormInput())); 512 $list->setValidators(array('title' => new sfValidatorString())); 513 $list->embedFormForEach('items', clone $list, 2); 514 $list->bind(array( 515 'title' => 'list title', 516 'items' => array( 517 array('title' => 'item 1'), 518 array('title' => 'item 2'), 519 array('title' => 'extra item'), 520 ), 521 )); 522 523 $t->isa_ok($list['items'][0]->getError(), 'sfValidatorErrorSchema', '"sfFormFieldSchema" is given an error schema when an extra embedded form is bound'); 524 525 // does this trigger a fatal error? 526 $list['items']->render(); 527 $t->pass('"sfFormFieldSchema" renders when an extra embedded form is bound'); 507 528 508 529 // ->getEmbeddedForms()