Example #1
0
 /**
  * @inheritdoc
  */
 public function renderHtml()
 {
     $html = Control::create('label', ['attribute' => $this->keywordsAttribute, 'model' => $this->model])->renderHtml() . '  ';
     $html .= Control::create('text', ['attribute' => $this->keywordsAttribute, 'model' => $this->model, 'options' => $this->keywordsHtmlOptions])->renderHtml();
     $html .= Control::create('label', ['attribute' => $this->keywordsTypeAttribute, 'model' => $this->model])->renderHtml() . '  ';
     $html .= Control::create('dropDown', ['attribute' => $this->keywordsTypeAttribute, 'model' => $this->model, 'items' => $this->keywordsTypeItems, 'options' => $this->keywordsTypeHtmlOptions])->renderHtml();
     return $html;
 }
Example #2
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     //参数异常判断,方便调试
     if (empty($this->items)) {
         throw new InvalidParamException('属性' . $this->attribute . '的单选框控件的items选项值为空!');
     }
     $this->items = Universal::getCallableValue($this->items);
 }
Example #3
0
        <table width="100%">
            <col class="th" />
            <col width="400" />
            <col />

            <?php 
    if (!isset($block['attributes'])) {
        throw new InvalidConfigException($block['name'] . '区间缺少控件属性!');
    }
    $attributes = $block['attributes'];
    //循环所有的属性并调用指定的html控件来渲染
    foreach ($attributes as $attribute => $configs) {
        if (isset($configs['type'])) {
            $type = $configs['type'];
            unset($configs['type']);
            $control = Control::create($type, $attribute, $model, null, $configs);
            if (isset($configs['label'])) {
                $label = $configs['label'];
            } elseif (isset($attributeLabels[$attribute])) {
                $label = $attributeLabels[$attribute];
            } else {
                $label = $attribute;
            }
            echo str_replace(['{label}', '{value}'], [$label, $control->renderValue()], $template);
        } else {
            throw new InvalidConfigException($attribute . '属性配置里缺少控件类型参数!');
        }
    }
    ?>

        </table>
Example #4
0
        <table width="100%">
            <col class="th" />
            <col width="400" />
            <col />

            <?php 
    if (!isset($block['attributes'])) {
        throw new InvalidConfigException($block['name'] . '区间缺少控件属性!');
    }
    $attributes = $block['attributes'];
    //循环所有的属性并调用指定的html控件来渲染
    foreach ($attributes as $attribute => $configs) {
        if (isset($configs['type'])) {
            $type = $configs['type'];
            unset($configs['type']);
            $control = Control::create($type, ['attribute' => $attribute, 'model' => $model] + $configs);
            if (isset($configs['label'])) {
                $label = $configs['label'];
            } elseif (isset($attributeLabels[$attribute])) {
                $label = $attributeLabels[$attribute];
            } else {
                $label = $attribute;
            }
            echo str_replace(['{label}', '{value}'], [$label, $control->renderValue()], $template);
        } else {
            throw new InvalidConfigException($attribute . '属性配置里缺少控件类型参数!');
        }
    }
    ?>

        </table>
Example #5
0
 /**
  * @inheritdoc
  */
 public function renderHtml()
 {
     //$html = Control::create('label', $this->attribute, $this->model)->renderHtml() . '&nbsp;&nbsp;';
     if (is_array($this->items)) {
         $items = $this->items;
     } elseif (is_string($this->items)) {
         $items = (new Query())->select([$this->keyAttribute, $this->valueAttribute])->from($this->items);
         if ($this->where !== null) {
             $items = $items->where($this->where);
         }
         $items = $items->all();
         $items = ArrayHelper::map($items, $this->keyAttribute, $this->valueAttribute);
     } elseif ($this->items instanceof \Closure) {
         $items = call_user_func($this->items, $this);
     } else {
         throw new InvalidConfigException('映射搜索组件' . $this->attribute . '属性items选项值参数类型错误!是否书写错误?');
     }
     $itemsLabel = '---' . $this->model->getAttributeLabel($this->attribute) . '---';
     $items = ['' => $itemsLabel] + $items;
     $html = Control::create('dropDown', $this->attribute, $this->model, null, ['items' => $items, 'htmlOptions' => $this->dropDownHtmlOptions])->renderHtml();
     return $html;
 }