From ec77ed7ef7f204fac1b8efa4cb92c9d0a53b801e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Wac=C5=82awczyk?= Date: Wed, 12 Sep 2012 15:33:57 +0200 Subject: [PATCH 1/2] [DomCrawler] Allows using multiselect through Form::setValues(). --- Form.php | 6 +++--- Tests/FormTest.php | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Form.php b/Form.php index 9106a232..1898e6c8 100644 --- a/Form.php +++ b/Form.php @@ -494,13 +494,13 @@ public function has($name) public function set($name, $value) { $target =& $this->get($name); - if (is_array($value)) { + if (!is_array($value) || $target instanceof Field\ChoiceFormField) { + $target->setValue($value); + } else { $fields = self::create($name, $value); foreach ($fields->all() as $k => $v) { $this->set($k, $v); } - } else { - $target->setValue($value); } } diff --git a/Tests/FormTest.php b/Tests/FormTest.php index b0cb8bc7..be54c9b7 100644 --- a/Tests/FormTest.php +++ b/Tests/FormTest.php @@ -273,6 +273,13 @@ public function testSetValues() $this->assertEquals(array('bar' => 'foo'), $form->getValues(), '->setValues() sets the values of fields'); } + public function testMultiselectSetValues() + { + $form = $this->createForm('
'); + $form->setValues(array('multi' => array("foo", "bar"))); + $this->assertEquals(array('multi' => array('foo', 'bar')), $form->getValues(), '->setValue() sets tehe values of select'); + } + public function testGetPhpValues() { $form = $this->createForm('
'); From 2bf63ba7b9d66784ff4fb075694bdc99e748fa62 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Thu, 4 Oct 2012 17:17:57 +0200 Subject: [PATCH 2/2] [2.1] Exclude tests from zips via gitattributes --- .gitattributes | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..e742c9b3 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +Tests/ export-ignore +phpunit.xml.dist export-ignore