當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Button::widget方法代碼示例

本文整理匯總了PHP中Button::widget方法的典型用法代碼示例。如果您正苦於以下問題:PHP Button::widget方法的具體用法?PHP Button::widget怎麽用?PHP Button::widget使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Button的用法示例。


在下文中一共展示了Button::widget方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: run

 /**
  * Executes the widget.
  */
 public function run()
 {
     Html::addCssClass($this->inputOptions, 'spinner-input form-control');
     $this->buttonsConfig = array_merge(['label' => ''], $this->buttonsConfig);
     if ($this->hasModel()) {
         $input = Html::activeTextInput($this->model, $this->attribute, $this->inputOptions);
     } else {
         $input = Html::textInput($this->name, $this->value, $this->inputOptions);
     }
     if ($this->buttonsLocation == self::BUTTONS_LOCATION_VERTICAL) {
         $this->buttonsConfig = array_merge($this->buttonsConfig, ['size' => Button::SIZE_MINI]);
     }
     $btnUp = Button::widget(array_merge($this->buttonsConfig, ['icon' => 'fa fa-angle-up', 'options' => ['class' => 'spinner-up']]));
     $btnDown = Button::widget(array_merge($this->buttonsConfig, ['icon' => 'fa fa-angle-down', 'options' => ['class' => 'spinner-down']]));
     if ($this->buttonsLocation == self::BUTTONS_LOCATION_VERTICAL) {
         $spinner = $input . Html::tag('div', $btnUp . $btnDown, ['class' => 'spinner-buttons input-group-btn btn-group-vertical']);
     } else {
         $spinner = Html::tag('div', $btnUp . $input . $btnDown, ['class' => 'spinner-buttons input-group-btn']);
     }
     echo Html::tag('div', Html::tag('div', $spinner, ['class' => 'input-group input-' . $this->size]), $this->options);
     SpinnerAsset::register($this->view);
     $this->registerPlugin('spinner');
 }
開發者ID:ayrozjlc,項目名稱:yii2-metronic-2,代碼行數:26,代碼來源:Spinner.php

示例2: renderButton

 /**
  * Renders the button.
  * @return string the rendering result
  */
 protected function renderButton()
 {
     //$label = Html::tag('span', $this->label, ['class' => 'hidden-sm hidden-xs']);
     $label = Html::tag('span', $this->label);
     if ($this->split) {
         $leftBtn = Button::widget($a = ArrayHelper::merge($this->button, ['label' => $label, 'encodeLabel' => false, 'tagName' => $this->tagName]));
         $rightBtn = Button::widget(ArrayHelper::merge($this->button, ['label' => '<i class="fa fa-angle-down"></i>', 'encodeLabel' => false, 'options' => $this->options, 'tagName' => $this->tagName]));
     } else {
         $label .= ' <i class="fa fa-angle-down"></i>';
         if (!isset($this->options['href'])) {
             $this->options['href'] = '#';
         }
         $leftBtn = Button::widget(ArrayHelper::merge($this->button, ['label' => $label, 'encodeLabel' => false, 'options' => $this->options, 'tagName' => $this->tagName]));
         $rightBtn = '';
     }
     return sprintf('%s%s', $leftBtn, $rightBtn);
 }
開發者ID:hustshenl,項目名稱:yii2-metronic-lite,代碼行數:21,代碼來源:ButtonDropdown.php

示例3: run

 /**
  * Executes the widget.
  */
 public function run()
 {
     if (empty($this->clientOptions['format'])) {
         $this->clientOptions['format'] = 'MM/DD/YYYY';
     }
     if (empty($this->labelDateFormat)) {
         $this->labelDateFormat = $this->clientOptions['format'];
     }
     if ($this->hasModel()) {
         $hiddenInput = Html::activeHiddenInput($this->model, $this->attribute);
         $input = Html::activeTextInput($this->model, $this->attribute);
         $name = Html::getInputName($this->model, $this->attribute);
         $value = $this->model->{$this->attribute};
         $this->options['id'] .= '-picker';
     } else {
         $hiddenInput = Html::hiddenInput($this->name, $this->value);
         $input = Html::textInput($this->name, $this->value, ['class' => 'form-control']);
         $name = $this->name;
         $value = $this->value;
     }
     $arrValue = array_map('trim', ($value = explode($this->separator, $value)) ? $value : []);
     $callback = '';
     $initJS = '';
     $lines = [];
     switch ($this->mode) {
         case self::MODE_ADVANCE:
             Html::addCssClass($this->options, 'btn ' . $this->type);
             $lines[] = $hiddenInput;
             $lines[] = Html::beginTag('div', $this->options);
             if (!empty($this->icon)) {
                 $lines[] = Html::tag('i', '', ['class' => $this->icon]) . ' ';
             }
             $lines[] = Html::tag('span', ' ');
             $lines[] = Html::tag('b', '', ['class' => 'fa fa-angle-down']);
             $lines[] = Html::endTag('div');
             $callback = "function (start, end) {\n                        \$('#{$this->options['id']} span')\n                            .html(start.format('{$this->labelDateFormat}')\n                            + '{$this->separator}' + end.format('{$this->labelDateFormat} '));\n                        // set value to hidden input\n                        \$('input[name=\"{$name}\"]').val(start.format('{$this->clientOptions['format']}')\n                            + '{$this->separator}' + end.format('{$this->clientOptions['format']}'));\n                    }";
             if (count($arrValue) == 2) {
                 $initJS = "\n                      !(function(\$){\n                        var el = \$('#{$this->options['id']}');\n                        el.data('daterangepicker')\n                            .setStartDate(moment('{$arrValue[0]}', '{$this->clientOptions['format']}'));\n                        el.data('daterangepicker')\n                            .setEndDate(moment('{$arrValue[1]}', '{$this->clientOptions['format']}'));\n                        el.find('span')\n                            .html(moment('{$arrValue[0]}', '{$this->clientOptions['format']}').format('{$this->labelDateFormat}')\n                                + '{$this->separator}'\n                                + moment('{$arrValue[1]}', '{$this->clientOptions['format']}').format('{$this->labelDateFormat} '));\n                       })(jQuery);\n                    ";
             }
             break;
         case self::MODE_INPUT:
             Html::addCssClass($this->options, 'input-group');
             $lines[] = Html::beginTag('div', $this->options);
             $lines[] = $input;
             $lines[] = Html::beginTag('span', ['class' => 'input-group-btn']);
             $lines[] = Button::widget(['label' => ' ', 'icon' => $this->icon, 'type' => $this->type, 'iconPosition' => Button::ICON_POSITION_RIGHT]);
             $lines[] = Html::endTag('span');
             $lines[] = Html::endTag('div');
             $callback = "function (start, end) {\n                        \$('#{$this->options['id']} input')\n                            .val(start.format('{$this->clientOptions['format']}')\n                            + '{$this->separator}' + end.format('{$this->clientOptions['format']} '));\n                        // set value to hidden input\n                        \$('input[name=\"{$name}\"]').val(start.format('{$this->clientOptions['format']}')\n                            + '{$this->separator}' + end.format('{$this->clientOptions['format']}'));\n                    }";
             if (count($arrValue) == 2) {
                 $initJS = "\n                      !(function(\$){\n                        var el = \$('#{$this->options['id']}');\n                        el.data('daterangepicker')\n                            .setStartDate(moment('{$arrValue[0]}', '{$this->clientOptions['format']}'));\n                        el.data('daterangepicker')\n                            .setEndDate(moment('{$arrValue[1]}', '{$this->clientOptions['format']}'));\n                        el.find('input')\n                            .val(moment('{$arrValue[0]}', '{$this->clientOptions['format']}').format('{$this->clientOptions['format']}')\n                                + '{$this->separator}'\n                                + moment('{$arrValue[1]}', '{$this->clientOptions['format']}').format('{$this->clientOptions['format']} '));\n                       })(jQuery);\n                    ";
             }
             break;
     }
     echo implode("\n", $lines);
     DateRangePickerAsset::register($this->view);
     $this->registerPlugin('daterangepicker', $callback);
     if (!empty($initJS)) {
         $this->view->registerJs($initJS, View::POS_READY);
     }
 }
開發者ID:ayrozjlc,項目名稱:yii2-metronic-2,代碼行數:64,代碼來源:DateRangePicker.php

示例4: renderButton

 /**
  * Generates the button dropdown.
  * @return string the rendering result.
  */
 protected function renderButton()
 {
     $this->addCssClass($this->buttonOptions, 'btn');
     if ($this->split) {
         $tag = 'button';
         $options = $this->buttonOptions;
         $this->buttonOptions['data-toggle'] = 'dropdown';
         $this->addCssClass($this->buttonOptions, 'dropdown-toggle');
         $splitButton = Button::widget(array('label' => '<span class="caret"></span>', 'encodeLabel' => false, 'options' => $this->buttonOptions));
     } else {
         $tag = 'a';
         $this->label .= ' <span class="caret"></span>';
         $options = $this->buttonOptions;
         if (!isset($options['href'])) {
             $options['href'] = '#';
         }
         $this->addCssClass($options, 'dropdown-toggle');
         $options['data-toggle'] = 'dropdown';
         $splitButton = '';
     }
     return Button::widget(array('tagName' => $tag, 'label' => $this->label, 'options' => $options, 'encodeLabel' => false)) . "\n" . $splitButton;
 }
開發者ID:abudayah,項目名稱:yiiwheels-custom,代碼行數:26,代碼來源:ButtonDropdown.php

示例5: renderToggleButton

 /**
  * Renders the toggle button.
  * @return string the rendering result
  */
 protected function renderToggleButton()
 {
     if (!empty($this->toggleButton)) {
         return Button::widget($this->toggleButton);
     } else {
         return null;
     }
 }
開發者ID:hustshenl,項目名稱:yii2-metronic-lite,代碼行數:12,代碼來源:Modal.php


注:本文中的Button::widget方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。