Esempio n. 1
0
 /**
  * @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);
 }
Esempio n. 2
0
 /**
  * @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);
     }
 }
Esempio n. 3
0
 /**
  * @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();
 }
Esempio n. 4
0
 /**
  * @param Element $element
  *
  * @return void
  */
 private function deselectOption(Element $element)
 {
     $element->removeAttribute('selected');
 }