コード例 #1
0
ファイル: FileInput.php プロジェクト: brick/brick
 /**
  * @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);
 }
コード例 #2
0
ファイル: ToggleButton.php プロジェクト: brick/brick
 /**
  * @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);
     }
 }
コード例 #3
0
ファイル: TextControl.php プロジェクト: brick/brick
 /**
  * @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();
 }
コード例 #4
0
ファイル: Select.php プロジェクト: brick/brick
 /**
  * @param Element $element
  *
  * @return void
  */
 private function deselectOption(Element $element)
 {
     $element->removeAttribute('selected');
 }