equal
deleted
inserted
replaced
|
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 * @api |
|
23 */ |
|
24 class InputFormField extends FormField |
|
25 { |
|
26 /** |
|
27 * Initializes the form field. |
|
28 * |
|
29 * @throws \LogicException When node type is incorrect |
|
30 */ |
|
31 protected function initialize() |
|
32 { |
|
33 if ('input' != $this->node->nodeName) { |
|
34 throw new \LogicException(sprintf('An InputFormField can only be created from an input tag (%s given).', $this->node->nodeName)); |
|
35 } |
|
36 |
|
37 if ('checkbox' == $this->node->getAttribute('type')) { |
|
38 throw new \LogicException('Checkboxes should be instances of ChoiceFormField.'); |
|
39 } |
|
40 |
|
41 if ('file' == $this->node->getAttribute('type')) { |
|
42 throw new \LogicException('File inputs should be instances of FileFormField.'); |
|
43 } |
|
44 |
|
45 $this->value = $this->node->getAttribute('value'); |
|
46 } |
|
47 } |