コード例 #1
0
ファイル: MiniColors.php プロジェクト: fangface/yii2-concord
 /**
  * Prepare the input fields for the input
  *
  * @return void
  */
 protected function prepareInput()
 {
     if ($this->hasModel()) {
         $this->sections['input'] = Html::activeTextInput($this->model, $this->attribute, $this->options);
     } else {
         $this->sections['input'] = Html::textInput($this->name, $this->value, $this->options);
     }
 }
コード例 #2
0
ファイル: Select2.php プロジェクト: fangface/yii2-concord
 /**
  * Prepare the input fields for the input
  *
  * @return void
  */
 protected function prepareInput()
 {
     if ($this->hasModel()) {
         $this->sections['input'] = Html::activeDropDownList($this->model, $this->attribute, $this->items, $this->options);
     } else {
         $this->sections['input'] = Html::dropDownList($this->model, $this->attribute, $this->items, $this->options);
     }
 }
コード例 #3
0
ファイル: DatePicker.php プロジェクト: fangface/yii2-concord
 /**
  * Prepare the input fields for the input
  *
  * @return void
  */
 protected function prepareInput()
 {
     if ($this->hasModel()) {
         if (!isset($this->options['value']) && $this->model->{$this->attribute} == '0000-00-00') {
             $this->options['value'] = '';
         }
         $this->sections['input'] = Html::activeTextInput($this->model, $this->attribute, $this->options);
     } else {
         $this->sections['input'] = Html::textInput($this->name, $this->value == '0000-00-00' ? '' : $this->value, $this->options);
     }
 }
コード例 #4
0
 /**
  * Prepare the input fields for the input
  *
  * @return void
  */
 protected function prepareInput()
 {
     if ($this->asComponent) {
         $this->addAddon(['content' => '<i></i>', 'options' => ['class' => 'color-component']], 'append', true);
         $this->setGroupOption('id', $this->options['id'] . '-wrap');
         $this->pluginOptions['component'] = '.color-component';
     }
     if ($this->hasModel()) {
         $this->sections['input'] = Html::activeTextInput($this->model, $this->attribute, $this->options);
     } else {
         $this->sections['input'] = Html::textInput($this->name, $this->value, $this->options);
     }
 }
コード例 #5
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;
 }
コード例 #6
0
 /**
  * Generates the button dropdown.
  * @return string the rendering result.
  */
 protected function renderButton()
 {
     Html::addCssClass($this->options, 'btn');
     $label = $this->label;
     if ($this->encodeLabel) {
         $label = Html::encode($label);
     }
     if ($this->split) {
         $options = $this->options;
         $this->options['data-toggle'] = 'dropdown';
         Html::addCssClass($this->options, ['toggle' => 'dropdown-toggle']);
         unset($this->options['id']);
         $splitButton = Button::widget(['label' => '<span class="caret"></span>', 'encodeLabel' => false, 'options' => $this->options, 'view' => $this->getView()]);
     } else {
         $label .= ' <span class="caret"></span>';
         $options = $this->options;
         if (!isset($options['href']) && $this->tagName === 'a') {
             $options['href'] = '#';
         }
         Html::addCssClass($options, ['toggle' => 'dropdown-toggle']);
         $options['data-toggle'] = 'dropdown';
         $splitButton = '';
     }
     return Button::widget(['tagName' => $this->tagName, 'label' => $label, 'options' => $options, 'encodeLabel' => false, 'view' => $this->getView()]) . "\n" . $splitButton;
 }
コード例 #7
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;
 }