diff --git a/src/Symfony/Component/DomCrawler/Form.php b/src/Symfony/Component/DomCrawler/Form.php
index c9c3c139b112b..78dacaa417e0f 100644
--- a/src/Symfony/Component/DomCrawler/Form.php
+++ b/src/Symfony/Component/DomCrawler/Form.php
@@ -246,8 +246,6 @@ public function has($name)
* Removes a field from the form.
*
* @param string $name The field name
- *
- * @throws \InvalidArgumentException when the name is malformed
*/
public function remove($name)
{
diff --git a/src/Symfony/Component/DomCrawler/FormFieldRegistry.php b/src/Symfony/Component/DomCrawler/FormFieldRegistry.php
index edb2788910de2..dbd08ff720765 100644
--- a/src/Symfony/Component/DomCrawler/FormFieldRegistry.php
+++ b/src/Symfony/Component/DomCrawler/FormFieldRegistry.php
@@ -26,8 +26,6 @@ class FormFieldRegistry
* Adds a field to the registry.
*
* @param FormField $field The field
- *
- * @throws \InvalidArgumentException when the name is malformed
*/
public function add(FormField $field)
{
@@ -52,8 +50,6 @@ public function add(FormField $field)
* Removes a field and its children from the registry.
*
* @param string $name The fully qualified name of the base field
- *
- * @throws \InvalidArgumentException when the name is malformed
*/
public function remove($name)
{
@@ -76,7 +72,6 @@ public function remove($name)
*
* @return mixed The value of the field
*
- * @throws \InvalidArgumentException when the name is malformed
* @throws \InvalidArgumentException if the field does not exist
*/
public function &get($name)
@@ -118,7 +113,6 @@ public function has($name)
* @param string $name The fully qualified name of the field
* @param mixed $value The value
*
- * @throws \InvalidArgumentException when the name is malformed
* @throws \InvalidArgumentException if the field does not exist
*/
public function set($name, $value)
@@ -199,24 +193,23 @@ private function walk(array $array, $base = '', array &$output = array())
* @param string $name The name of the field
*
* @return string[] The list of segments
- *
- * @throws \InvalidArgumentException when the name is malformed
*/
private function getSegments($name)
{
if (preg_match('/^(?P[^[]+)(?P(\[.*)|$)/', $name, $m)) {
$segments = array($m['base']);
while (!empty($m['extra'])) {
- if (preg_match('/^\[(?P.*?)\](?P.*)$/', $m['extra'], $m)) {
+ $extra = $m['extra'];
+ if (preg_match('/^\[(?P.*?)\](?P.*)$/', $extra, $m)) {
$segments[] = $m['segment'];
} else {
- throw new \InvalidArgumentException(sprintf('Malformed field path "%s"', $name));
+ $segments[] = $extra;
}
}
return $segments;
}
- throw new \InvalidArgumentException(sprintf('Malformed field path "%s"', $name));
+ return array($name);
}
}
diff --git a/src/Symfony/Component/DomCrawler/Tests/FormTest.php b/src/Symfony/Component/DomCrawler/Tests/FormTest.php
index 5bfbfb98245dc..3035e8d371d96 100644
--- a/src/Symfony/Component/DomCrawler/Tests/FormTest.php
+++ b/src/Symfony/Component/DomCrawler/Tests/FormTest.php
@@ -345,18 +345,6 @@ public function testGetSetValue()
}
}
- public function testSetValueOnMultiValuedFieldsWithMalformedName()
- {
- $form = $this->createForm('');
-
- try {
- $form['foo[bar'] = 'bar';
- $this->fail('->offsetSet() throws an \InvalidArgumentException exception if the name is malformed.');
- } catch (\InvalidArgumentException $e) {
- $this->assertTrue(true, '->offsetSet() throws an \InvalidArgumentException exception if the name is malformed.');
- }
- }
-
public function testDisableValidation()
{
$form = $this->createForm('');
+ $form['[t:dbt%3adate;]data_daterange_enddate_value'] = 'bar';
+
+ $registry->remove('[t:dbt%3adate;]data_daterange_enddate_value');
}
/**
@@ -717,15 +693,6 @@ public function testFormFieldRegistryGetThrowAnExceptionWhenTheFieldDoesNotExist
$registry->get('foo');
}
- /**
- * @expectedException \InvalidArgumentException
- */
- public function testFormFieldRegistrySetThrowAnExceptionWhenTheNameIsMalformed()
- {
- $registry = new FormFieldRegistry();
- $registry->set('[foo]', null);
- }
-
/**
* @expectedException \InvalidArgumentException
*/