コード例 #1
0
ファイル: ActiveField.php プロジェクト: fangface/yii2-concord
 /**
  * Renders a static input
  *
  * @param array $options the tag options
  * @return $this
  */
 public function staticInput($options = [])
 {
     if (isset($options['value'])) {
         $content = $options['value'];
         unset($options['value']);
     } else {
         $content = Html::getAttributeValue($this->model, $this->attribute);
     }
     Html::addCssClass($options, 'form-control-static');
     $this->parts['{input}'] = Html::tag('p', $content, $options);
     $this->template = str_replace("\n{hint}", '', $this->template);
     $this->template = str_replace("\n{error}", '', $this->template);
     return $this;
 }
コード例 #2
0
 /**
  * Parses and returns addon content
  *
  * @param string|array $addon the addon parameter
  * @param string $type type of addon prepend or append
  * @return string
  */
 protected function getAddonContent($addon, $type = 'append')
 {
     if (!is_array($addon)) {
         return $addon;
     }
     if (is_string($addon)) {
         return $addon;
     } elseif (isset($addon['content'])) {
         // a single addon
         $addons = [$addon];
     } else {
         // multiple addons
         $addons = $addon;
     }
     $allContent = '';
     foreach ($addons as $k => $addon) {
         $content = ArrayHelper::getValue($addon, 'content', '');
         if ($content == '') {
             if (isset($addon['class'])) {
                 // assume an icon needs to be output
                 $content = Html::tag('i', '', $addon);
             }
         }
         if (ArrayHelper::getValue($addon, 'raw', false) == true) {
             // content already prepared
             $allContent .= "\n" . $content;
         } else {
             $options = ArrayHelper::getValue($addon, 'options', []);
             $tag = ArrayHelper::remove($options, 'tag', 'span');
             if (ArrayHelper::getValue($addon, 'asButton', false) == true) {
                 Html::addCssClass($options, 'input-group-btn');
                 $allContent .= "\n" . Html::tag($tag, $content, $options);
             } else {
                 Html::addCssClass($options, 'input-group-addon' . ($type == 'append' ? ' addon-after' : ''));
                 $allContent .= "\n" . Html::tag($tag, $content, $options);
             }
         }
     }
     return $allContent;
 }