Author: Kris.Wallsmith
Date: 2010-04-06 15:33:53 +0200 (Tue, 06 Apr 2010)
New Revision: 28994
Modified:
branches/1.3/lib/form/sfForm.class.php
branches/1.3/test/unit/form/sfFormTest.php
branches/1.4/lib/form/sfForm.class.php
branches/1.4/test/unit/form/sfFormTest.php
Log:
[1.3, 1.4] fixed merging of values from form to field schema (closes #8415)
Modified: branches/1.3/lib/form/sfForm.class.php
===================================================================
--- branches/1.3/lib/form/sfForm.class.php 2010-04-06 12:11:00 UTC (rev
28993)
+++ branches/1.3/lib/form/sfForm.class.php 2010-04-06 13:33:53 UTC (rev
28994)
@@ -1143,7 +1143,7 @@
{
if (null === $this->formFieldSchema)
{
- $values = $this->isBound ? $this->taintedValues :
array_merge($this->widgetSchema->getDefaults(), $this->defaults);
+ $values = $this->isBound ? $this->taintedValues : $this->defaults +
$this->widgetSchema->getDefaults();
$this->formFieldSchema = new sfFormFieldSchema($this->widgetSchema,
null, null, $values, $this->errorSchema);
}
Modified: branches/1.3/test/unit/form/sfFormTest.php
===================================================================
--- branches/1.3/test/unit/form/sfFormTest.php 2010-04-06 12:11:00 UTC (rev
28993)
+++ branches/1.3/test/unit/form/sfFormTest.php 2010-04-06 13:33:53 UTC (rev
28994)
@@ -10,7 +10,7 @@
require_once(dirname(__FILE__).'/../../bootstrap/unit.php');
-$t = new lime_test(157);
+$t = new lime_test(159);
class FormTest extends sfForm
{
@@ -944,3 +944,25 @@
));
$t->is($f->getJavaScripts(), array('/path/to/a/foo.js', '/path/to/a/bar.js'),
'->getJavaScripts() returns the stylesheets of all widgets');
$t->is($f->getStylesheets(), array('/path/to/a/foo.css' => 'all',
'/path/to/a/bar.css' => 'all'), '->getStylesheets() returns the JavaScripts of
all widgets');
+
+// ->getFormFieldSchema()
+$t->diag('->getFormFieldSchema()');
+
+class NumericFieldsForm extends sfForm
+{
+ public function configure()
+ {
+ $this->setWidgets(array(
+ '5' => new sfWidgetFormInputText(),
+ ));
+
+ $this->setValidators(array(
+ '5' => new sfValidatorString(),
+ ));
+ }
+}
+
+$f = new NumericFieldsForm(array('5' => 'default'));
+$t->is_deeply($f->getFormFieldSchema()->getValue(), array('5' => 'default'),
'->getFormFieldSchema() includes default numeric fields');
+$f->bind(array('5' => 'bound'));
+$t->is_deeply($f->getFormFieldSchema()->getValue(), array('5' => 'bound'),
'->getFormFieldSchema() includes bound numeric fields');
Modified: branches/1.4/lib/form/sfForm.class.php
===================================================================
--- branches/1.4/lib/form/sfForm.class.php 2010-04-06 12:11:00 UTC (rev
28993)
+++ branches/1.4/lib/form/sfForm.class.php 2010-04-06 13:33:53 UTC (rev
28994)
@@ -1143,7 +1143,7 @@
{
if (null === $this->formFieldSchema)
{
- $values = $this->isBound ? $this->taintedValues :
array_merge($this->widgetSchema->getDefaults(), $this->defaults);
+ $values = $this->isBound ? $this->taintedValues : $this->defaults +
$this->widgetSchema->getDefaults();
$this->formFieldSchema = new sfFormFieldSchema($this->widgetSchema,
null, null, $values, $this->errorSchema);
}
Modified: branches/1.4/test/unit/form/sfFormTest.php
===================================================================
--- branches/1.4/test/unit/form/sfFormTest.php 2010-04-06 12:11:00 UTC (rev
28993)
+++ branches/1.4/test/unit/form/sfFormTest.php 2010-04-06 13:33:53 UTC (rev
28994)
@@ -10,7 +10,7 @@
require_once(dirname(__FILE__).'/../../bootstrap/unit.php');
-$t = new lime_test(157);
+$t = new lime_test(159);
class FormTest extends sfForm
{
@@ -944,3 +944,25 @@
));
$t->is($f->getJavaScripts(), array('/path/to/a/foo.js', '/path/to/a/bar.js'),
'->getJavaScripts() returns the stylesheets of all widgets');
$t->is($f->getStylesheets(), array('/path/to/a/foo.css' => 'all',
'/path/to/a/bar.css' => 'all'), '->getStylesheets() returns the JavaScripts of
all widgets');
+
+// ->getFormFieldSchema()
+$t->diag('->getFormFieldSchema()');
+
+class NumericFieldsForm extends sfForm
+{
+ public function configure()
+ {
+ $this->setWidgets(array(
+ '5' => new sfWidgetFormInputText(),
+ ));
+
+ $this->setValidators(array(
+ '5' => new sfValidatorString(),
+ ));
+ }
+}
+
+$f = new NumericFieldsForm(array('5' => 'default'));
+$t->is_deeply($f->getFormFieldSchema()->getValue(), array('5' => 'default'),
'->getFormFieldSchema() includes default numeric fields');
+$f->bind(array('5' => 'bound'));
+$t->is_deeply($f->getFormFieldSchema()->getValue(), array('5' => 'bound'),
'->getFormFieldSchema() includes bound numeric fields');
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.