|
@@ -69,41 +69,6 @@ class Form implements \ArrayAccess
|
|
|
return $this->node;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Gets the value of a field.
|
|
|
- *
|
|
|
- * @param string $name The field name
|
|
|
- *
|
|
|
- * @throws \InvalidArgumentException if the field does not exist
|
|
|
- */
|
|
|
- public function getValue($name)
|
|
|
- {
|
|
|
- if (!$this->hasField($name)) {
|
|
|
- throw new \InvalidArgumentException(sprintf('The form field "%s" does not exist', $name));
|
|
|
- }
|
|
|
-
|
|
|
- return $this->fields[$name]->getValue();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Sets the value of a field.
|
|
|
- *
|
|
|
- * @param string $name The field name
|
|
|
- * @param string|array $value The value of the field
|
|
|
- *
|
|
|
- * @throws \InvalidArgumentException if the field does not exist
|
|
|
- */
|
|
|
- public function setValue($name, $value)
|
|
|
- {
|
|
|
- if (!$this->hasField($name)) {
|
|
|
- throw new \InvalidArgumentException(sprintf('The form field "%s" does not exist', $name));
|
|
|
- }
|
|
|
-
|
|
|
- $this->fields[$name]->setValue($value);
|
|
|
-
|
|
|
- return $this;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Sets the value of the fields.
|
|
|
*
|
|
@@ -112,7 +77,7 @@ class Form implements \ArrayAccess
|
|
|
public function setValues(array $values)
|
|
|
{
|
|
|
foreach ($values as $name => $value) {
|
|
|
- $this->setValue($name, $value);
|
|
|
+ $this[$name] = $value;
|
|
|
}
|
|
|
|
|
|
return $this;
|
|
@@ -337,7 +302,7 @@ class Form implements \ArrayAccess
|
|
|
*/
|
|
|
public function offsetExists($name)
|
|
|
{
|
|
|
- return $this->hasValue($name);
|
|
|
+ return $this->hasField($name);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -349,7 +314,11 @@ class Form implements \ArrayAccess
|
|
|
*/
|
|
|
public function offsetGet($name)
|
|
|
{
|
|
|
- return $this->getValue($name);
|
|
|
+ if (!$this->hasField($name)) {
|
|
|
+ throw new \InvalidArgumentException(sprintf('The form field "%s" does not exist', $name));
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->fields[$name]->getValue();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -362,7 +331,11 @@ class Form implements \ArrayAccess
|
|
|
*/
|
|
|
public function offsetSet($name, $value)
|
|
|
{
|
|
|
- $this->setValue($name, $value);
|
|
|
+ if (!$this->hasField($name)) {
|
|
|
+ throw new \InvalidArgumentException(sprintf('The form field "%s" does not exist', $name));
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->fields[$name]->setValue($value);
|
|
|
}
|
|
|
|
|
|
/**
|