scratch – Blame information for rev
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
87 | office | 1 | <?php |
2 | |||
3 | /* |
||
4 | * This file is part of the Symfony package. |
||
5 | * |
||
6 | * (c) Fabien Potencier <fabien@symfony.com> |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
11 | |||
12 | namespace Symfony\Component\DomCrawler\Field; |
||
13 | |||
14 | /** |
||
15 | * InputFormField represents an input form field (an HTML input tag). |
||
16 | * |
||
17 | * For inputs with type of file, checkbox, or radio, there are other more |
||
18 | * specialized classes (cf. FileFormField and ChoiceFormField). |
||
19 | * |
||
20 | * @author Fabien Potencier <fabien@symfony.com> |
||
21 | */ |
||
22 | class InputFormField extends FormField |
||
23 | { |
||
24 | /** |
||
25 | * Initializes the form field. |
||
26 | * |
||
27 | * @throws \LogicException When node type is incorrect |
||
28 | */ |
||
29 | protected function initialize() |
||
30 | { |
||
31 | if ('input' !== $this->node->nodeName && 'button' !== $this->node->nodeName) { |
||
32 | throw new \LogicException(sprintf('An InputFormField can only be created from an input or button tag (%s given).', $this->node->nodeName)); |
||
33 | } |
||
34 | |||
35 | if ('checkbox' === strtolower($this->node->getAttribute('type'))) { |
||
36 | throw new \LogicException('Checkboxes should be instances of ChoiceFormField.'); |
||
37 | } |
||
38 | |||
39 | if ('file' === strtolower($this->node->getAttribute('type'))) { |
||
40 | throw new \LogicException('File inputs should be instances of FileFormField.'); |
||
41 | } |
||
42 | |||
43 | $this->value = $this->node->getAttribute('value'); |
||
44 | } |
||
45 | } |