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


PHP widgets\InputWidget类代码示例

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


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

示例1: init

 public function init()
 {
     $this->id = $this->hasModel() ? Html::getInputId($this->model, $this->attribute) : $this->id;
     $this->_options = ['serverUrl' => Url::to(['upload']), 'initialFrameWidth' => '100%', 'initialFrameHeight' => '300', 'lang' => strtolower(Yii::$app->language) == 'en-us' ? 'en' : 'zh-cn'];
     $this->clientOptions = ArrayHelper::merge($this->_options, $this->clientOptions);
     parent::init();
 }
开发者ID:h1cms,项目名称:h1cms-ueditor,代码行数:7,代码来源:Ueditor.php

示例2: 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

示例3: init

 public function init()
 {
     parent::init();
     \Yii::setAlias('@webuploader', __DIR__);
     if (empty($this->driver)) {
         $this->driver = isset(\Yii::$app->params['webuploader_driver']) ? \Yii::$app->params['webuploader_driver'] : 'local';
     }
     if ($this->driver == 'local') {
         // 初始化@static别名,默认@web/static,最好根据自己的需求提前设置好@static别名
         $static = \Yii::getAlias('@static', false);
         $staticroot = \Yii::getAlias('@staticroot', false);
         if (!$static || !$staticroot) {
             \Yii::setAlias('@static', '@web/static');
             \Yii::setAlias('@staticroot', '@webroot/static');
         }
     }
     $this->server = $this->server ?: Url::to(['/site/webupload', 'driver' => $this->driver]);
     $this->options['boxId'] = isset($this->options['boxId']) ? $this->options['boxId'] : 'picker';
     $this->options['previewWidth'] = isset($this->options['previewWidth']) ? $this->options['previewWidth'] : '250';
     $this->options['previewHeight'] = isset($this->options['previewHeight']) ? $this->options['previewHeight'] : '150';
     if ($this->hasModel()) {
         $this->hiddenInput = Html::activeHiddenInput($this->model, $this->attribute);
     } else {
         $this->hiddenInput = Html::hiddenInput($this->name, $this->value);
     }
 }
开发者ID:yidashi,项目名称:yii2-webuploader,代码行数:26,代码来源:Webuploader.php

示例4: init

 public function init()
 {
     if (!isset($this->options['class'])) {
         $this->options['class'] = 'form-control';
     }
     if (!isset($this->jsOptions['isRTL'])) {
         $this->jsOptions['isRTL'] = true;
     }
     if (!isset($this->jsOptions['changeMonth'])) {
         $this->jsOptions['changeMonth'] = true;
     }
     if (!isset($this->jsOptions['changeYear'])) {
         $this->jsOptions['changeYear'] = true;
     }
     if (!isset($this->jsOptions['dateFormat'])) {
         $this->jsOptions['dateFormat'] = 'yy/mm/dd';
     }
     if (!isset($this->jsOptions['weekStart'])) {
         $this->jsOptions['weekStart'] = 0;
     }
     if (!isset($this->value)) {
         $this->setValue();
     }
     parent::init();
 }
开发者ID:ahb360,项目名称:yii2-admin360,代码行数:25,代码来源:JalaliDatePicker.php

示例5: init

 /**
  * @throws \yii\base\InvalidConfigException
  */
 public function init()
 {
     parent::init();
     $this->registerMessages();
     if ($this->maxNumberOfFiles > 1) {
         $this->multiple = true;
     }
     if ($this->hasModel()) {
         $this->name = $this->name ?: Html::getInputName($this->model, $this->attribute);
         $this->value = $this->value ?: Html::getAttributeValue($this->model, $this->attribute);
     }
     if (!array_key_exists('name', $this->clientOptions)) {
         $this->clientOptions['name'] = $this->name;
     }
     if ($this->multiple && $this->value && !is_array($this->value)) {
         throw new InvalidParamException('In "multiple" mode, value must be an array.');
     }
     if (!array_key_exists('fileparam', $this->url)) {
         $this->url['fileparam'] = $this->getFileInputName();
     }
     if (!$this->files && $this->value) {
         $this->files = $this->multiple ? $this->value : [$this->value];
     }
     $this->clientOptions = ArrayHelper::merge(['url' => Url::to($this->url), 'multiple' => $this->multiple, 'sortable' => $this->sortable, 'maxNumberOfFiles' => $this->maxNumberOfFiles, 'maxFileSize' => $this->maxFileSize, 'minFileSize' => $this->minFileSize, 'acceptFileTypes' => $this->acceptFileTypes, 'files' => $this->files, 'messages' => ['maxNumberOfFiles' => Yii::t($this->messagesCategory, 'Maximum number of files exceeded', [], 'en'), 'acceptFileTypes' => Yii::t($this->messagesCategory, 'File type not allowed', [], 'en'), 'maxFileSize' => Yii::t($this->messagesCategory, 'File is too large', [], 'en'), 'minFileSize' => Yii::t($this->messagesCategory, 'File is too small', [], 'en')]], $this->clientOptions);
 }
开发者ID:yiioverflow,项目名称:yii2-file-kit,代码行数:28,代码来源:Upload.php

示例6: init

 public function init()
 {
     if (is_null($this->name)) {
         throw new InvalidConfigException('Name property must be specified.');
     }
     parent::init();
     $view = $this->getView();
     JoyrideAsset::register($view);
     if (isset($this->joyride_options['cookieMonster']) && $this->joyride_options['cookieMonster'] === true) {
         $this->publishAndRegisterFile('@vendor/branchonline/yii2-joyride/src/assets/jquery.cookie.js', ['depends' => JoyrideAsset::className()]);
     }
     $joyride_options_strings = [];
     $this->joyride_options['autoStart'] = 'true';
     foreach ($this->joyride_options as $k => $v) {
         if (is_bool($v)) {
             $value = $v ? 'true' : 'false';
         } else {
             $value = "'" . $v . "'";
         }
         $joyride_options_strings[] = $k . ': ' . $value;
     }
     $view->registerJs('console.log($("#' . $this->getId() . '")); $("#' . $this->getId() . '").joyride({
          ' . implode(', ', $joyride_options_strings) . '
     });');
 }
开发者ID:branchonline,项目名称:yii2-joyride,代码行数:25,代码来源:Joyride.php

示例7: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     self::registerTranslations();
     if ($this->uploadUrl === null) {
         throw new InvalidConfigException(Yii::t('cropper', 'MISSING_ATTRIBUTE', ['attribute' => 'uploadUrl']));
     } else {
         $this->uploadUrl = rtrim(Yii::getAlias($this->uploadUrl), '/') . '/';
     }
     if ($this->KeyFolder) {
         $this->previewUrl = $this->previewUrl . '/' . $this->KeyFolder;
     }
     if ($this->label == '') {
         $this->label = Yii::t('cropper', 'DEFAULT_LABEL');
     }
     // keep aspect ratio
     $ratio1 = $this->width / $this->height;
     $ratio2 = $this->display_width / $this->display_height;
     if ($ratio1 != $ratio2) {
         if ($ratio1 > 1) {
             $target_width = $this->display_width;
             $target_height = $this->display_width / $ratio1;
         } else {
             $target_width = $this->display_height * $ratio1;
             $target_height = $this->display_height;
         }
         $this->display_width = $target_width;
         $this->display_height = $target_height;
     }
 }
开发者ID:plathir,项目名称:yii2-smart-cropper,代码行数:33,代码来源:Widget.php

示例8: init

 public function init()
 {
     parent::init();
     if (!isset($this->htmlOptions['class'])) {
         $this->htmlOptions['class'] = 'editor';
     }
 }
开发者ID:hiscaler,项目名称:yii2-ueditor,代码行数:7,代码来源:UEditor.php

示例9: init

 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     if (empty($this->id)) {
         $this->id = $this->hasModel() ? Html::getInputId($this->model, $this->attribute) : $this->getId();
     }
     if (empty($this->name)) {
         $this->name = $this->hasModel() ? Html::getInputName($this->model, $this->attribute) : $this->id;
     }
     if (empty($this->value) && $this->hasModel() && $this->model->hasAttribute($this->attribute)) {
         $this->value = $this->model->getAttribute($this->attribute);
     }
     if (!$this->autoHeightEnable) {
         if (empty($this->width)) {
             $this->width = '100%';
         }
         if (empty($this->height)) {
             $this->height = '350';
         }
     }
     $options = ['id' => $this->id, 'style' => 'width:100%;height:350px'];
     $this->options = array_merge($options, $this->options);
     $jsOptions = ['serverUrl' => Url::to(['ueditor', 'type' => 'ueditor']), 'autoHeightEnable' => $this->autoHeightEnable, 'autoFloatEnable' => true, 'textarea' => $this->name];
     $this->jsOptions = array_merge($jsOptions, $this->jsOptions);
 }
开发者ID:crazyfd,项目名称:yii2-ueditor,代码行数:28,代码来源:Ueditor.php

示例10: init

 public function init()
 {
     parent::init();
     $this->view = $this->getView();
     AssetBundle::register($this->view);
     $this->cropperOptions = array_merge($this->cropperOptions, $this->defaultCropperOptions);
 }
开发者ID:sadovojav,项目名称:yii2-image-cutter,代码行数:7,代码来源:Cutter.php

示例11: init

 /**
  * @throws \yii\base\InvalidConfigException
  */
 public function init()
 {
     parent::init();
     $this->registerMessages();
     if ($this->maxNumberOfFiles > 1 || $this->multiple) {
         $this->multiple = true;
     }
     if ($this->hasModel()) {
         $this->name = $this->name ?: Html::getInputName($this->model, $this->attribute);
         $this->value = $this->value ?: Html::getAttributeValue($this->model, $this->attribute);
     }
     if (!array_key_exists('name', $this->clientOptions)) {
         $this->clientOptions['name'] = $this->name;
     }
     if ($this->multiple && $this->value && !is_array($this->value)) {
         throw new InvalidParamException('In "multiple" mode, value must be an array.');
     }
     if (!array_key_exists('fileparam', $this->url)) {
         $this->url['fileparam'] = $this->getFileInputName();
     }
     if (!$this->files && $this->value) {
         $this->files = $this->multiple ? $this->value : [$this->value];
     }
     if ($this->files) {
         foreach ($this->files as &$file) {
             if (!isset($file['alias_url']) && is_array($file)) {
                 $option = isset($this->clientOptions['baseUrlAttribute']) ? $this->clientOptions['baseUrlAttribute'] : null;
                 $file['alias_url'] = $option ? isset($file[$option]) ? Yii::getAlias($file[$option]) : null : null;
             }
         }
     }
     $this->clientOptions = ArrayHelper::merge(['url' => Url::to($this->url), 'multiple' => $this->multiple, 'sortable' => $this->sortable, 'maxNumberOfFiles' => $this->maxNumberOfFiles, 'maxFileSize' => $this->maxFileSize, 'minFileSize' => $this->minFileSize, 'acceptFileTypes' => $this->acceptFileTypes, 'files' => $this->files, 'showPreviewFilename' => $this->showPreviewFilename, 'pathAttribute' => 'path', 'baseUrlAttribute' => 'base_url', 'pathAttributeName' => 'path', 'baseUrlAttributeName' => 'base_url', 'messages' => ['maxNumberOfFiles' => Yii::t($this->messagesCategory, 'Maximum number of files exceeded'), 'acceptFileTypes' => Yii::t($this->messagesCategory, 'File type not allowed'), 'maxFileSize' => Yii::t($this->messagesCategory, 'File is too large'), 'minFileSize' => Yii::t($this->messagesCategory, 'File is too small')]], $this->clientOptions);
 }
开发者ID:sonrac,项目名称:yii2-file-kit,代码行数:36,代码来源:Upload.php

示例12: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (is_null($this->language)) {
         $this->language = Yii::$app->language;
         if (is_null($this->language)) {
             $this->language = 'en-US';
         }
     }
     $formatter = Yii::$app->getFormatter();
     if (is_null($this->items)) {
         $this->items = $formatter->booleanFormat;
         if (is_null($this->items)) {
             $this->items = [Yii::t('yii', 'No', [], $this->language), Yii::t('yii', 'Yes', [], $this->language)];
         }
     }
     if (is_null($this->prompt)) {
         $this->prompt = $formatter->nullDisplay;
         if (is_null($this->prompt)) {
             $this->prompt = Yii::t('yii', '(not set)', [], $this->language);
         }
     }
     Html::addCssClass($this->options, 'form-control');
     if (array_key_exists('value', $this->options)) {
         $this->value = $this->options['value'];
         unset($this->options['value']);
     }
     if (is_string($this->prompt) && !array_key_exists('prompt', $this->options)) {
         $this->options['prompt'] = strip_tags($this->prompt);
     }
 }
开发者ID:ivan-chkv,项目名称:yii2-boost,代码行数:34,代码来源:InputBoolean.php

示例13: init

 public function init()
 {
     parent::init();
     if (!array_key_exists('id', $this->clientOptions)) {
         $this->clientOptions['id'] = $this->id;
     }
 }
开发者ID:Liv1020,项目名称:cms,代码行数:7,代码来源:ComboTextInputWidget.php

示例14: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->target === null) {
         $this->target = '#' . $this->getId();
     }
 }
开发者ID:Brother-Simon,项目名称:yii2-wechat,代码行数:10,代码来源:FileApiInputWidget.php

示例15: init

 public function init()
 {
     parent::init();
     if ($this->dateFormat === null) {
         $this->dateFormat = Yii::$app->formatter->dateFormat;
     }
 }
开发者ID:omnilight,项目名称:yii2-bootstrap-datepicker,代码行数:7,代码来源:DatePicker.php


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