Changeset 27749
- Timestamp:
- 02/08/10 19:48:39 (1 month ago)
- Files:
-
- branches/1.3/lib/plugins/sfDoctrinePlugin/lib/form/sfFormDoctrine.class.php (modified) (2 diffs)
- branches/1.3/lib/plugins/sfDoctrinePlugin/test/unit/form/sfFormDoctrineTest.php (modified) (1 diff)
- branches/1.3/lib/plugins/sfPropelPlugin/lib/form/sfFormPropel.class.php (modified) (1 diff)
- branches/1.4/lib/plugins/sfDoctrinePlugin/lib/form/sfFormDoctrine.class.php (modified) (2 diffs)
- branches/1.4/lib/plugins/sfDoctrinePlugin/test/unit/form/sfFormDoctrineTest.php (modified) (1 diff)
- branches/1.4/lib/plugins/sfPropelPlugin/lib/form/sfFormPropel.class.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.3/lib/plugins/sfDoctrinePlugin/lib/form/sfFormDoctrine.class.php
r24971 r27749 228 228 protected function updateDefaultsFromObject() 229 229 { 230 $defaults = $this->getDefaults(); 231 230 232 // update defaults for the main object 231 233 if ($this->isNew()) 232 234 { 233 $this->setDefaults(array_merge($this->getObject()->toArray(false), $this->getDefaults())); 234 } 235 else 236 { 237 $this->setDefaults(array_merge($this->getDefaults(), $this->getObject()->toArray(false))); 238 } 239 240 $defaults = $this->getDefaults(); 235 $defaults = $this->getObject()->toArray(false) + $defaults; 236 } 237 else 238 { 239 $defaults = $this->getDefaults() + $this->getObject()->toArray(false); 240 } 241 241 242 foreach ($this->embeddedForms as $name => $form) 242 243 { … … 247 248 } 248 249 } 250 249 251 $this->setDefaults($defaults); 250 252 } branches/1.3/lib/plugins/sfDoctrinePlugin/test/unit/form/sfFormDoctrineTest.php
r24537 r27749 4 4 include dirname(__FILE__).'/../../bootstrap/functional.php'; 5 5 6 $t = new lime_test(10); 6 $t = new lime_test(11); 7 8 // ->__construct() 9 $t->diag('->__construct()'); 10 11 class DefaultValuesForm extends ArticleForm 12 { 13 public function configure() 14 { 15 $this->widgetSchema[1] = new sfWidgetFormInputText(); 16 $this->validatorSchema[1] = new sfValidatorPass(); 17 $this->setDefault(1, '==DEFAULT_VALUE=='); 18 } 19 } 20 21 $form = new DefaultValuesForm(); 22 $defaults = $form->getDefaults(); 23 $t->is($defaults[1], '==DEFAULT_VALUE==', '->__construct() allows ->configure() to set defaults on numeric fields'); 7 24 8 25 // ->embedRelation() branches/1.3/lib/plugins/sfPropelPlugin/lib/form/sfFormPropel.class.php
r24068 r27749 192 192 if ($this->isNew()) 193 193 { 194 $this->setDefaults( array_merge($this->getObject()->toArray(BasePeer::TYPE_FIELDNAME), $this->getDefaults()));194 $this->setDefaults($this->getObject()->toArray(BasePeer::TYPE_FIELDNAME) + $this->getDefaults()); 195 195 } 196 196 else 197 197 { 198 $this->setDefaults( array_merge($this->getDefaults(), $this->getObject()->toArray(BasePeer::TYPE_FIELDNAME)));198 $this->setDefaults($this->getDefaults() + $this->getObject()->toArray(BasePeer::TYPE_FIELDNAME)); 199 199 } 200 200 } branches/1.4/lib/plugins/sfDoctrinePlugin/lib/form/sfFormDoctrine.class.php
r24971 r27749 228 228 protected function updateDefaultsFromObject() 229 229 { 230 $defaults = $this->getDefaults(); 231 230 232 // update defaults for the main object 231 233 if ($this->isNew()) 232 234 { 233 $this->setDefaults(array_merge($this->getObject()->toArray(false), $this->getDefaults())); 234 } 235 else 236 { 237 $this->setDefaults(array_merge($this->getDefaults(), $this->getObject()->toArray(false))); 238 } 239 240 $defaults = $this->getDefaults(); 235 $defaults = $this->getObject()->toArray(false) + $defaults; 236 } 237 else 238 { 239 $defaults = $this->getDefaults() + $this->getObject()->toArray(false); 240 } 241 241 242 foreach ($this->embeddedForms as $name => $form) 242 243 { … … 247 248 } 248 249 } 250 249 251 $this->setDefaults($defaults); 250 252 } branches/1.4/lib/plugins/sfDoctrinePlugin/test/unit/form/sfFormDoctrineTest.php
r24537 r27749 4 4 include dirname(__FILE__).'/../../bootstrap/functional.php'; 5 5 6 $t = new lime_test(10); 6 $t = new lime_test(11); 7 8 // ->__construct() 9 $t->diag('->__construct()'); 10 11 class DefaultValuesForm extends ArticleForm 12 { 13 public function configure() 14 { 15 $this->widgetSchema[1] = new sfWidgetFormInputText(); 16 $this->validatorSchema[1] = new sfValidatorPass(); 17 $this->setDefault(1, '==DEFAULT_VALUE=='); 18 } 19 } 20 21 $form = new DefaultValuesForm(); 22 $defaults = $form->getDefaults(); 23 $t->is($defaults[1], '==DEFAULT_VALUE==', '->__construct() allows ->configure() to set defaults on numeric fields'); 7 24 8 25 // ->embedRelation() branches/1.4/lib/plugins/sfPropelPlugin/lib/form/sfFormPropel.class.php
r24068 r27749 192 192 if ($this->isNew()) 193 193 { 194 $this->setDefaults( array_merge($this->getObject()->toArray(BasePeer::TYPE_FIELDNAME), $this->getDefaults()));194 $this->setDefaults($this->getObject()->toArray(BasePeer::TYPE_FIELDNAME) + $this->getDefaults()); 195 195 } 196 196 else 197 197 { 198 $this->setDefaults( array_merge($this->getDefaults(), $this->getObject()->toArray(BasePeer::TYPE_FIELDNAME)));198 $this->setDefaults($this->getDefaults() + $this->getObject()->toArray(BasePeer::TYPE_FIELDNAME)); 199 199 } 200 200 }

