构建表单元素
@return string
422004
private function buildElements(){

        $eles = $this->getElements();
        $groups = $this->elementsGroup($eles);
        $formNs = $this->formNs;

        $elementsHtml = '';
        foreach ($groups as $k=>$v){
            $elements = isset($v['elements']) ? $v['elements'] : null;
            if ($elements){

                if ($k != 'base'){
                    $elementsHtml .= '<fieldset class="'.$formNs.'form-field'.$k.'" id="'.$formNs.'form-field-'.$k.'" >';
                    if (isset($v['title']) && $v['title']){
                        $elementsHtml .= '<legend>'.$v['title'].'</legend>';
                    }

                }
                foreach ($elements as $ele){
                    $type = $ele['type'];
                    if ($type == 'text' || $type == 'hidden' || $type == 'password' || $type == 'email' || $type == 'file' || $type =='button' || $type == 'number'){
                        $elementsHtml .= $this->buildInput($ele);
                    }
                    if ($type == 'textarea') {
                        $elementsHtml .= $this->buildTextarea($ele);
                    }
                    if ($type == 'select'){
                        $elementsHtml .= $this->buildSelect($ele);
                    }
                    if ($type == 'radio'){
                        $elementsHtml .= $this->buildRadio($ele);
                    }
                    if ($type == 'checkbox'){
                        $elementsHtml .= $this->buildCheckbox($ele);
                    }
                    if ($type == 'submit' || $type == 'reset'){
                        $elementsHtml .= $this->buildSubmit($ele);
                    }
                }
                if ($k != 'base'){
                    $elementsHtml .= '</fieldset>';
                }


            }
        }




        return $elementsHtml;
    }
777857
public function getInputFilterSpecification()
    {
        $spec = array();
        foreach ($this->getElements() as $element) {
            $name = (string) $element->getName();
            $spec[$name] = array(
                'name' => $name,
            );
        }
        return $spec;
    }
713116
public function toQTI(){

        $template = static::getTemplateQti();
        $variables = $this->getTemplateQtiVariables();
        if(isset($variables['attributes'])){
            $variables['attributes'] = $this->xmlizeOptions($variables['attributes'], true);
        }
        $tplRenderer = new taoItems_models_classes_TemplateRenderer($template, $variables);
        $returnValue = $tplRenderer->render();

        return (string) $returnValue;
    }
1374156
public function toString()
    {
        if (substr($this->name, -2) === '()') {
            return PHP_EOL . substr($this->name, 0, -2) . '(' . implode($this->glue, $this->elements) . ')';
        } else {
            return PHP_EOL . $this->name . ' ' . implode($this->glue, $this->elements);
        }
    }
875253
public function ToString()
	{
		$sb = array_reduce( $this->ToList(), function( $carry, /** @var XPath2Item $item */ $item )
		{
			$carry[] = $item->ToString();
			return $carry;
		}, array() );
		$s = implode( ", ", $sb );
		return $s;

		$sb = array();
		foreach ( $this->ToList() as $node )
		{
			$sb[] = is_object( $node ) ? $node->ToString() : $node;
		}

		$s = implode( ", ", $sb );

		return empty( $s)
			? "<empty>"
			: $s;
	}
11334
public function render() {
		$parts = [];
		
		if (empty($this->elements)) {
			return '';
		}
		
		// Elements
		foreach ($this->elements as $element) {
			if (! $element->isEmpty()) {
				$parts[] = $element->assemble();
			}
		}
		
		return implode(PHP_EOL, $parts);
	}
1186433
public function outputElement() : string
    {
        $atts = [];
        foreach ($this->attributes as $name => $value) {
            $atts[] = $name . '="' . $value . '"';
        }
        $return = '<textarea ' . implode(' ', $atts) . '>' . "\n";
        $return .= $this->getValue();
        $return .= '</textarea>';
        return $return;
    }
386045
public function getElementId()
    {
        $id = $this->getAttribute('elementId');
        if (null === $id && null !== $this->element) {
            $id = $this->elementId = $this->element->id;
        }

        return $id;
    }
1129421
public function getIterator()
    {
        $iterator = new \ArrayIterator($this);
        foreach ($iterator as $key => $value) {
            $Property = new ReflectionPropertyX($this, $key);
            if ($key == "_id" || stripos($Property->_ignore, "show") !== false) continue;

            $this->_key = $key;
            $this->_value = $value;
            $var_type = strtolower($Property->_var);        //@var
            $method1 = $key . "_text";
            $method2 = $key;

            if (method_exists($this, $method1)) {
                $content = $this->{$method1} ();
            } elseif (method_exists($this, $method2)) {
                $content = $this->{$method2} ();
            } else {
                if ($var_type == "bool" || $var_type == "boolean") {
                    $content = $this->_show_bool($value);    //PHPDoc里面预定义了@var为boolean的
                } elseif ($var_type == "array" || preg_match('/\[\]/', $var_type)) {
                    $content = $this->_show_array($value);    //PHPDoc里面预定义了@var为array的
                } elseif ($var_type == "file") {
                    $content = $this->_show_file($value);
                } else {
                    $content = $this->_show_string($value);
                }
            }

            $name = $Property->_name ?: $key;
            yield $name => $content;
        }
    }
1106532
public function getElements()
    {
        foreach ($this->elements as $name => $element) {
            $this->resolveXRef($name);
        }

        return $this->elements;
    }
931588
public function getTemplateSource(): string
    {
        $content = @file_get_contents($this->tplSrcPath);
        if ($content === false) {
            Application::$app->dispatchEvent(ApplicationErrorEvent::createCustom(500, '读取模板文件' . $this->tplSrcPath . '失败'));
            return '<!--error-->';
        }
        // 与布局文件合并
        if ($this->layoutPath !== null) {
            $this->processLayout($content);
        }
        return $content;
    }
944650
private function render()
    {
        if (empty($this->element)) {
            $this->textInput();
        }
        
        if (!isset($this->parts['{label}'])) {
            $this->label($this->label);
        }
        
        if (!isset($this->parts['{initValue}'])) {
            $this->initValue(null);
        }
    
        return str_replace([
            '{label}', '{initValue}', '{model}',
        ], [
            $this->parts['{label}'],
            $this->parts['{initValue}'],
            $this->getNgModel(),
        ], $this->element);
    }
1002327
public function render(){
        //获取组件的class
        $class = self::getClass(self::$set['component_name']);
        //获取组件的属性
        $component_attr = $class::attr();
        //外部调用设定代替默认值
        //赋值一个id的属性
        self::$set['id'] = self::$uniqid_id;

        $class::$attr = array_merge($component_attr ,self::$set);


        if(isset($component_attr['layFilter'])){ //如果组件有这个属性 ，但却没有设置，则默认 是 uniqid_id
            $class::$attr['layFilter'] = ( !isset(self::$set['layFilter']) )  ? self::$uniqid_id  : self::$set['layFilter'];
        }

        //记录当前页面使用了哪些组件
        array_push(self::$components ,[
            'component_name' => self::$set['component_name'] ,
            'uniqid_id' => self::$uniqid_id,
            'set' => $class::$attr
        ]);

        $dom = $class::dom();

        //销毁静态变量 保留了 self::$components 用于 调用组件的js
        self::$set = $class::$attr = $class::$id = null;

        return $dom;
    }
729203
public function onGetJSONData()
    {
        $iElementID = Input::get('element_id');
        $obElementItem = $this->makeItem($iElementID);

        return $obElementItem->toJSON();
    }
1133054
public function html() {
    if (!$this->isMorphed())
      $this->morph();
      
    $html = NULL;
    foreach ($this->elements as $el) {
      $html .= $el->html()."\n";
    }
      
    return $html;
  }
340408
public function renderElements()
    {
        $returnValue = '';


		foreach($this->elements as $element){

			 if($this->getElementGroup($element->getName()) !== ''){
			 	continue;	//render grouped elements after
			 }

			 if(!is_null($this->getDecorator()) && !($element instanceof tao_helpers_form_elements_Hidden)){
			 	$returnValue .= $this->getDecorator()->preRender();
			 }

             if(!$this->isValid() && $element->getError()) {
                $element->addClass('error');
             }

			 //render element
			 $returnValue .= $element->render();

			 //render element help
			 $help = trim($element->getHelp());
			 if(!empty($help)){
				 if(!is_null($this->getDecorator('help'))){
			 		$returnValue .= $this->getDecorator('help')->preRender();
			 	}

			 	$returnValue .= $help;

				if(!is_null($this->getDecorator('help'))){
			 		$returnValue .= $this->getDecorator('help')->postRender();
			 	}
			 }

			 //render error message
			 if(!$this->isValid() && $element->getError()){
			 	if(!is_null($this->getDecorator('error'))){
			 		$returnValue .= $this->getDecorator('error')->preRender();
			 	}

			 	$returnValue .= nl2br($element->getError());

				if(!is_null($this->getDecorator('error'))){
			 		$returnValue .= $this->getDecorator('error')->postRender();
			 	}
			 }

			 if(!is_null($this->getDecorator()) && !($element instanceof tao_helpers_form_elements_Hidden)){
			 	$returnValue .= $this->getDecorator()->postRender();
			 }
		}

		$subGroupDecorator = null;
		if(!is_null($this->getDecorator('group'))){
			$decoratorClass = get_class($this->getDecorator('group'));
			$subGroupDecorator = new $decoratorClass();
		}

		//render group
		foreach($this->groups as $groupName => $group){

			if(!is_null($this->getDecorator('group'))){
				$this->getDecorator('group')->setOption('id', $groupName);
				if(isset($group['options'])){
					if(isset($group['options']['class'])){
						$currentClasses = array_map('trim', explode(' ',$this->getDecorator('group')->getOption('cssClass')));
						if(!in_array($group['options']['class'], $currentClasses)){
							$currentClasses[] = $group['options']['class'];
							$this->getDecorator('group')->setOption('cssClass', implode(' ', array_unique($currentClasses)));
						}
					}
				}
				$returnValue .= $this->getDecorator('group')->preRender();
			}
			$returnValue .= $group['title'];
			if(!is_null($subGroupDecorator)){
				$returnValue .= $subGroupDecorator->preRender();
			}
			foreach($group['elements'] as $elementName){
				 if($this->getElementGroup($elementName) === $groupName && $element = $this->getElement( $elementName )){

				 	if(!is_null($this->getDecorator())){// && !($element instanceof tao_helpers_form_elements_Hidden) ){

					 	$returnValue .= $this->getDecorator()->preRender();
					 }

					 //render element
                     if ( ! $this->isValid() && $element->getError()) {
                         $element->addClass( 'error' );
                     }
					 $returnValue .= $element->render();

					 //render element help
					 $help = trim($element->getHelp());
					 if(!empty($help)){
						 if(!is_null($this->getDecorator('help'))){
					 		$returnValue .= $this->getDecorator('help')->preRender();
					 	}

					 	$returnValue .= $help;

						if(!is_null($this->getDecorator('help'))){
					 		$returnValue .= $this->getDecorator('help')->postRender();
					 	}
					 }

					 //render error message
					 if(!$this->isValid() && $element->getError()){
					 	if(!is_null($this->getDecorator('error'))){
					 		$returnValue .= $this->getDecorator('error')->preRender();
					 	}
					 	$returnValue .= nl2br($element->getError());
						if(!is_null($this->getDecorator('error'))){
					 		$returnValue .= $this->getDecorator('error')->postRender();
					 	}
					 }

					 if(!is_null($this->getDecorator())){// && !($element instanceof tao_helpers_form_elements_Hidden) ){
					 	$returnValue .= $this->getDecorator()->postRender();
					 }
				 }
			}
			if(!is_null($subGroupDecorator)){
				$returnValue .= $subGroupDecorator->postRender();
			}
			if(!is_null($this->getDecorator('group'))){
				$returnValue .= $this->getDecorator('group')->postRender();
				$this->getDecorator('group')->setOption('id', '');
			}
		}


        return $returnValue;
    }
866184
public static function dom(){
        $attr = self::$attr;
//        $attr['param'] = self::strToArray($attr['param']);
//        p($attr['param']);

        $label = explode('|',$attr['label']);
        $linkfield = explode('|',$attr['linkfield']);

        $str = '';
        foreach($label as $k => $v){

            $str .= <<<EOT
    <label class="layui-form-label">{$v}</label>
    <div class="layui-input-inline">
        <select name="{$linkfield[$k]}" lay-verify="{$attr['layVerify']}" >
            <option value="">请选择</option>
        </select>
    </div>
EOT;

        }

        $dom = <<<EOT
            <div class="layui-form-item {$attr['component_name']}" component-name="linkselect" id="{$attr['id']}">
                    {$str}
                    <div class="layui-form-mid layui-word-aux">{$attr['helpinfo']}</div>
                </div>
EOT;

        return $dom;
    }