/** * @param Element $element * @return FileInput * @throws UnexpectedElementException */ public static function create(Element $element) { if (!$element->is('input')) { throw new UnexpectedElementException('Expected input element, got ' . $element->getTagName()); } $type = strtolower($element->getAttribute('type')); if ($type != 'file') { throw new UnexpectedElementException('Expected input type=file, got ' . $type); } return new FileInput($element); }
/** * @param Element $element * @return ToggleButton * @throws UnexpectedElementException */ public static function create(Element $element) { if (!$element->is('input')) { throw new UnexpectedElementException('Expected input element, got ' . $element->getTagName()); } switch ($type = $element->getAttribute('type')) { case 'checkbox': return new CheckBox($element); case 'radio': return new RadioButton($element); default: throw new UnexpectedElementException('Expected input type=checkbox|radiobutton, got ' . $type); } }
/** * @param Element $element * @return TextControl * @throws UnexpectedElementException */ public static function create(Element $element) { switch (strtolower($element->getTagName())) { case 'input': switch (strtolower($element->getAttribute('type'))) { case 'text': case 'password': case 'hidden': case 'email': case 'number': case 'search': case 'tel': case 'url': return new TextInput($element); } break; case 'textarea': return new TextArea($element); } throw new UnexpectedElementException(); }
/** * @param Element $element * * @return void */ private function deselectOption(Element $element) { $element->removeAttribute('selected'); }