当前位置: 首页>>代码示例>>PHP>>正文


PHP InputWidget::run方法代码示例

本文整理汇总了PHP中yii\widgets\InputWidget::run方法的典型用法代码示例。如果您正苦于以下问题:PHP InputWidget::run方法的具体用法?PHP InputWidget::run怎么用?PHP InputWidget::run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\widgets\InputWidget的用法示例。


在下文中一共展示了InputWidget::run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

    function run()
    {
        parent::run();
        $wid = $this->options['id'];
        echo Html::activeHiddenInput($this->model, $this->attribute);
        echo Html::beginTag('div', ['id' => $wid . '-buttons', 'class' => 'input-group btn-group']);
        $items = PublishBehavior::getPublishedOptions();
        $colors = PublishBehavior::getPublishedColors();
        foreach ($items as $key => $item) {
            echo Html::button($item, ['data' => ['value' => $key], 'class' => $key == $this->model->{$this->attribute} ? 'btn btn-' . $colors[$key] . ' active' : 'btn btn-default']);
        }
        echo Html::endTag('div');
        $js_colors = Json::encode($colors);
        $js = <<<JS
 \$('#{$wid}-buttons').find('button').each(function(){
   \$(this).on('click',function(){
     \$('#{$wid}-buttons').find('button').each(function(){
        \$(this).removeClass('btn-danger btn-warning btn-success btn-info active');
        \$(this).addClass('btn-default');
     });
     var color={$js_colors};
     \$(this).removeClass('btn-default');
     \$(this).addClass('btn-'+color[\$(this).data('value')]+' active');
     \$('#{$wid}').val(\$(this).data('value'))
   });  
});               
JS;
        $this->view->registerJs($js);
    }
开发者ID:claudejanz,项目名称:yii2-toolbox,代码行数:29,代码来源:PublishWidget.php

示例2: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     parent::run();
     if ($this->hasModel()) {
         echo Html::activeTextInput($this->model, $this->attribute, $this->options);
     } else {
         echo Html::textInput($this->name, $this->value, $this->options);
     }
     $this->registerPlugin();
 }
开发者ID:modernkernel,项目名称:yii2-datetimepicker,代码行数:13,代码来源:DateTimePicker.php

示例3: run

 /**
  * {@inheritDoc}
  * @see \yii\base\Widget::run()
  */
 public function run()
 {
     if (isset($this->options['disabled'])) {
         $this->disabled = true;
     }
     $this->applyPluginSettings();
     parent::run();
     if (method_exists($this, 'renderWidget')) {
         $this->renderWidget();
     }
 }
开发者ID:fangface,项目名称:yii2-concord,代码行数:15,代码来源:InputWidget.php

示例4: run

 public function run()
 {
     //        echo '<table class="table table-bordered">';
     //        foreach ($this->view->params[$this->name] as $item) {
     //            echo '<tr>';
     //            foreach($item as $value) {
     //                echo '<td>';
     //                echo $value;
     //                echo '</td>';
     //            }
     //            echo '</tr>';
     //        }
     //        echo '</table>';
     parent::run();
 }
开发者ID:Polymedia,项目名称:BI-Platform-v3,代码行数:15,代码来源:ProjectWidget.php

示例5: run

 public function run()
 {
     echo '<table class="table table-bordered">';
     foreach ($this->view->params[$this->name] as $item) {
         echo '<tr>';
         if (is_array($item)) {
             foreach ($item as $value) {
                 echo '<td>';
                 echo $value;
                 echo '</td>';
             }
         } else {
             echo $item;
         }
         echo '</tr>';
     }
     echo '</table>';
     parent::run();
 }
开发者ID:Polymedia,项目名称:BI-Platform-v3,代码行数:19,代码来源:TableWidget.php

示例6: run

    public function run()
    {
        parent::run();
        DateTimePickerAsset::register($this->view);
        echo $this->renderInput();
        if ($this->renderIcon) {
            echo $this->renderIcon;
        }
        $js = 'jQuery(\'#' . $this->getId() . '\').datetimepicker(' . Json::encode($this->getClientOptions()) . ');';
        if ($this->renderIcon) {
            $js .= 'jQuery(\'#' . $this->getId() . '\').next().on(\'click\', function(){
    var $input = jQuery(\'#' . $this->getId() . '\');
    if(!$input.attr(\'disabled\') && !$input.attr(\'readonly\')){
        $input.datetimepicker(\'show\');
    }
    return false;
});';
        }
        $this->view->registerJs($js);
    }
开发者ID:bloody-hell,项目名称:yii2-xdan-datetimepicker,代码行数:20,代码来源:DateTimePicker.php

示例7: run

 public function run()
 {
     parent::run();
     echo Html::beginTag($tag = ArrayHelper::remove($this->options, 'tag', 'div'), $this->options);
     echo Html::beginTag($listTag = ArrayHelper::remove($this->listOptions, 'tag', 'div'), $this->listOptions);
     if ($values = $this->hasModel() ? $this->model->{$this->attribute} : $this->value) {
         foreach ($values as $key => $value) {
             echo $this->renderItem($key, $value);
         }
     } else {
         echo $this->renderItem(null, null);
     }
     echo Html::endTag($listTag);
     if (is_callable($this->addLinkOptions)) {
         echo call_user_func($this->addLinkOptions, $this->renderItem(null, null), $this);
     } else {
         Html::addCssClass($this->addLinkOptions, $this->addLinkClass());
         $this->addLinkOptions['data-sample-item'] = $this->renderItem(null, null);
         echo Html::a(Html::tag('span', '', ['class' => 'glyphicon glyphicon-plus']) . self::t('multistring', 'Add...'), '#', $this->addLinkOptions);
     }
     echo Html::endTag($tag);
     $this->view->registerJs('jQuery(\'#' . $this->getId() . '\').multiString(' . Json::encode($this->clientOptions) . ')');
 }
开发者ID:novokshonovev,项目名称:multi-string-widget,代码行数:23,代码来源:MultiStringWidget.php

示例8: run

 /**
  * Run widget
  */
 public function run()
 {
     parent::run();
     if (!isset($this->wrapperOptions)) {
         $this->wrapperOptions = [];
     }
     if (!isset($this->wrapperOptions['id'])) {
         $this->wrapperOptions['id'] = $this->id;
     }
     if (!isset($this->wrapperOptions['style'])) {
         $this->wrapperOptions['style'] = 'width: 100%; height: 500px;';
     }
     SelectMapLocationAssets::$googleMapApiKey = $this->googleMapApiKey;
     SelectMapLocationAssets::register($this->view);
     // getting inputs ids
     $address = Html::getInputId($this->model, $this->attribute);
     $latitude = Html::getInputId($this->model, $this->attributeLatitude);
     $longitude = Html::getInputId($this->model, $this->attributeLongitude);
     $jsOptions = ArrayHelper::merge($this->jsOptions, ['address' => '#' . $address, 'latitude' => '#' . $latitude, 'longitude' => '#' . $longitude, 'draggable' => $this->draggable]);
     // message about not founded addess
     if (!isset($jsOptions['addressNotFound'])) {
         $hasMainCategory = isset(Yii::$app->i18n->translations['*']) || isset(Yii::$app->i18n->translations['main']);
         $jsOptions['addressNotFound'] = $hasMainCategory ? Yii::t('main', 'Address not found') : 'Address not found';
     }
     $this->view->registerJs(new JsExpression('
         $(document).ready(function() {
             $(\'#' . $this->wrapperOptions['id'] . '\').selectLocation(' . Json::encode($jsOptions) . ');
         });
     '));
     $mapHtml = Html::tag('div', '', $this->wrapperOptions);
     $mapHtml .= Html::activeHiddenInput($this->model, $this->attributeLatitude);
     $mapHtml .= Html::activeHiddenInput($this->model, $this->attributeLongitude);
     if (is_callable($this->renderWidgetMap)) {
         return call_user_func_array($this->renderWidgetMap, [$mapHtml]);
     }
     return Html::activeInput('text', $this->model, $this->attribute, $this->textOptions) . $mapHtml;
 }
开发者ID:kalyabin,项目名称:yii2-select-google-map-location,代码行数:40,代码来源:SelectMapLocationWidget.php

示例9: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     parent::run();
     $view = $this->getView();
     if (is_array($this->maskOptions)) {
         if ($this->hasModel()) {
             $this->maskOptions = ArrayHelper::merge($this->maskOptions, ['options' => $this->options, 'model' => $this->model, 'attribute' => $this->attribute]);
         } else {
             $this->maskOptions = ArrayHelper::merge($this->maskOptions, ['options' => $this->options, 'name' => $this->name, 'value' => $this->value]);
         }
         $input = MaskedInput::widget($this->maskOptions);
     } else {
         $input = $this->hasModel() ? Html::activeTextInput($this->model, $this->attribute, $this->options) : Html::textInput($this->name, $this->value, $this->options);
     }
     $options = Json::encode($this->pluginOptions);
     $callback = isset($this->callback) ? ", {$this->callback}" : '';
     $script = "moment.locale('{$this->locale}');";
     $script .= "\$('#{$this->options['id']}').daterangepicker({$options}{$callback});";
     $view->registerJs($script);
     echo strtr($this->template, ['{input}' => $input]);
     MomentAsset::$locale = $this->locale;
     MomentAsset::register($view);
     DateRangePickerAsset::register($view);
 }
开发者ID:jino5577,项目名称:yii2-date-range-picker,代码行数:27,代码来源:DateRangePicker.php

示例10: run

    public function run()
    {
        //prepare data
        $view = $this->getView();
        //render input for results
        if ($this->_renderInput) {
            if ($this->hasModel()) {
                echo Html::activeHiddenInput($this->model, $this->attribute, $this->options);
            } else {
                echo Html::hiddenInput($this->name, $this->value, $this->options);
            }
        }
        //render editor container
        $containerOptions = $this->containerOptions;
        $tag = ArrayHelper::remove($containerOptions, 'tag', 'div');
        echo Html::tag($tag, '', $containerOptions);
        //prepare client options
        $clientOptions = $this->clientOptions;
        $clientOptions['schema'] = $this->schema;
        ArrayHelper::remove($clientOptions, 'startval');
        $clientOptions = Json::encode($clientOptions);
        //prepare element IDs
        $widgetId = $this->id;
        $inputId = $this->inputId;
        $containerId = $this->containerOptions['id'];
        //register js code
        $view->registerJs(<<<JS
var {$widgetId} = new JSONEditor(document.getElementById('{$containerId}'), {$clientOptions});
try {
    var initialValue = JSON.parse(document.getElementById('{$inputId}').value);
    {$widgetId}.setValue(initialValue);
} catch (e) {
    console.log('Could not parse initial value for {$widgetId}');
}
{$widgetId}.on('change', function() {
    document.getElementById('{$inputId}').value = JSON.stringify({$widgetId}.getValue());
});
JS
, $view::POS_READY);
        parent::run();
    }
开发者ID:drsdre,项目名称:yii2-json-editor,代码行数:41,代码来源:JsonEditorWidget.php

示例11: run

 /**
  * @return string
  */
 public function run()
 {
     parent::run();
     $this->registerJs();
     return $this->hasModel() ? Html::activeDropDownList($this->model, $this->attribute, $this->items, $this->options) : Html::dropDownList($this->name, $this->value, $this->items, $this->options);
 }
开发者ID:brussens,项目名称:yii2-bootstrap-select,代码行数:9,代码来源:Widget.php

示例12: run

 public function run()
 {
     parent::run();
     $this->renderWidget();
 }
开发者ID:sanchezzzhak,项目名称:kak-select2,代码行数:5,代码来源:Select2.php

示例13: run

 /**
  * Run the widget
  */
 public function run()
 {
     parent::run();
     if ($this->showExport) {
         echo $this->renderExportForm();
     }
     echo Html::endTag('div');
     echo Html::endTag('div');
 }
开发者ID:kangqf,项目名称:yii2-markdown,代码行数:12,代码来源:MarkdownEditor.php

示例14: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     parent::run();
     $this->registerAssets();
     echo $this->renderInput();
 }
开发者ID:levi-putna,项目名称:yii2-image-input,代码行数:9,代码来源:ImageInput.php

示例15: run

 public function run()
 {
     \yii\jui\AutoComplete::widget();
     parent::run();
 }
开发者ID:jimminababan,项目名称:sangkilbiz3,代码行数:5,代码来源:AutoComplete.php


注:本文中的yii\widgets\InputWidget::run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。