コード例 #1
0
ファイル: SearchBuilder.php プロジェクト: suyuanen/trotri
 /**
  * 初始化表单元素
  * @return \views\bootstrap\widgets\SearchBuilder
  */
 public function initElements()
 {
     $elements = $this->elements_object->getElementsRender();
     if ($elements === array()) {
         return $this;
     }
     $extends = isset($this->_tplVars['elements']) ? (array) $this->_tplVars['elements'] : array();
     $columns = isset($this->_tplVars['columns']) ? (array) $this->_tplVars['columns'] : array();
     if ($columns === array()) {
         return $this;
     }
     $_elements = array();
     foreach ($columns as $columnName) {
         if (!isset($elements[$columnName])) {
             continue;
         }
         $element = $elements[$columnName];
         if (!is_array($element)) {
             continue;
         }
         if (isset($extends[$columnName]) && is_array($extends[$columnName])) {
             $element = array_merge($element, $extends[$columnName]);
         }
         $object = isset($element['__object__']) ? $element['__object__'] : '';
         $type = isset($element['type']) ? $element['type'] : 'text';
         if ($object === '' && isset(self::$_typeObjectMap[$type])) {
             $object = self::$_typeObjectMap[$type];
         }
         $placeholder = isset($element['placeholder']) ? $element['placeholder'] : (isset($element['label']) ? $element['label'] : '');
         $options = isset($element['options']) ? (array) $element['options'] : array();
         if ($options !== array() && $placeholder !== '') {
             $options = array('' => '--' . $placeholder . '--') + $options;
         }
         $_elements[$columnName] = array('type' => $type, '__object__' => $object, 'placeholder' => $placeholder, 'options' => $options);
     }
     // 设置查询按钮
     $_elements['_button_search_'] = array('type' => 'button', '__object__' => 'views\\bootstrap\\components\\form\\ButtonElement', 'label' => Text::_('CFG_SYSTEM_GLOBAL_SEARCH'), 'glyphicon' => 'search', 'class' => 'btn btn-primary btn-block');
     parent::setElements($_elements);
 }
コード例 #2
0
ファイル: FormBuilder.php プロジェクト: suyuanen/trotri
 /**
  * (non-PHPdoc)
  * @see \tfc\mvc\form\FormBuilder::initElements()
  */
 public function initElements()
 {
     $elements = $this->elements_object->getElementsRender();
     if ($elements === array()) {
         return $this;
     }
     $extends = isset($this->_tplVars['elements']) ? (array) $this->_tplVars['elements'] : array();
     $columns = isset($this->_tplVars['columns']) ? (array) $this->_tplVars['columns'] : array();
     if ($columns === array()) {
         return $this;
     }
     $_elements = array();
     foreach ($columns as $columnName) {
         if (substr($columnName, 0, 8) === '_button_') {
             $funcName = 'get' . str_replace('_', '', $columnName);
             if ($columnName === '_button_cancel_') {
                 $element = ComponentsBuilder::$funcName($this->elements_object->getLLU());
             } else {
                 $element = ComponentsBuilder::$funcName();
             }
         } else {
             if (!isset($elements[$columnName])) {
                 continue;
             }
             $element = $elements[$columnName];
             if (!is_array($element)) {
                 continue;
             }
             if (isset($extends[$columnName]) && is_array($extends[$columnName])) {
                 $element = array_merge($element, $extends[$columnName]);
             }
         }
         if (!isset($element['__object__']) && isset($element['type'])) {
             $type = $element['type'];
             if (isset(self::$_typeObjectMap[$type])) {
                 $element['__object__'] = self::$_typeObjectMap[$type];
             }
         }
         if (!isset($element['__tid__'])) {
             $element['__tid__'] = self::DEFAULT_TID;
         }
         $_elements[$columnName] = $element;
     }
     parent::setElements($_elements);
 }