You are here

public function FormFieldRegistry::set in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/dom-crawler/FormFieldRegistry.php \Symfony\Component\DomCrawler\FormFieldRegistry::set()

Set the value of a field and its children.

Parameters

string $name The fully qualified name of the field:

mixed $value The value:

Throws

\InvalidArgumentException when the name is malformed

\InvalidArgumentException if the field does not exist

File

vendor/symfony/dom-crawler/FormFieldRegistry.php, line 124

Class

FormFieldRegistry
This is an internal class that must not be used directly.

Namespace

Symfony\Component\DomCrawler

Code

public function set($name, $value) {
  $target =& $this
    ->get($name);
  if (!is_array($value) && $target instanceof Field\FormField || $target instanceof Field\ChoiceFormField) {
    $target
      ->setValue($value);
  }
  elseif (is_array($value)) {
    $fields = self::create($name, $value);
    foreach ($fields
      ->all() as $k => $v) {
      $this
        ->set($k, $v);
    }
  }
  else {
    throw new \InvalidArgumentException(sprintf('Cannot set value on a compound field "%s".', $name));
  }
}