public function ChoiceFormField::addChoice in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/dom-crawler/Field/ChoiceFormField.php \Symfony\Component\DomCrawler\Field\ChoiceFormField::addChoice()
Adds a choice to the current ones.
This method should only be used internally.
Parameters
\DOMElement $node:
Throws
\LogicException When choice provided is not multiple nor radio
File
- vendor/
symfony/ dom-crawler/ Field/ ChoiceFormField.php, line 160
Class
- ChoiceFormField
- ChoiceFormField represents a choice form field.
Namespace
Symfony\Component\DomCrawler\FieldCode
public function addChoice(\DOMElement $node) {
if (!$this->multiple && 'radio' !== $this->type) {
throw new \LogicException(sprintf('Unable to add a choice for "%s" as it is not multiple or is not a radio button.', $this->name));
}
$option = $this
->buildOptionValue($node);
$this->options[] = $option;
if ($node
->hasAttribute('checked')) {
$this->value = $option['value'];
}
}