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


PHP Html::getAttributeValue方法代码示例

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


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

示例1: renderSavedValueInput

 public function renderSavedValueInput()
 {
     if ($this->hasModel()) {
         $value = Html::getAttributeValue($this->model, $this->attribute);
     } else {
         $value = $this->value;
     }
     if ($value !== null && $value !== '') {
         // format value according to saveDateFormat
         try {
             $value = Yii::$app->formatter->asDate($value, $this->saveDateFormat);
         } catch (InvalidParamException $e) {
             // ignore exception and keep original value if it is not a valid date
         }
     }
     $this->options['savedValueInputID'] = $this->options['id'] . '-saved-value';
     $options = $this->options;
     $options['id'] = $options['savedValueInputID'];
     $options['value'] = $value;
     // render hidden input
     if ($this->hasModel()) {
         $contents = Html::activeHiddenInput($this->model, $this->attribute, $options);
     } else {
         $contents = Html::hiddenInput($this->name, $value, $options);
     }
     return $contents;
 }
开发者ID:michael-vostrikov,项目名称:books-test,代码行数:27,代码来源:DatePicker.php

示例2: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     $inputId = $this->options['id'];
     $hasModel = $this->hasModel();
     if (array_key_exists('value', $this->options)) {
         $value = $this->options['value'];
     } elseif ($hasModel) {
         $value = Html::getAttributeValue($this->model, $this->attribute);
     } else {
         $value = $this->value;
     }
     $options = array_merge($this->options, ['multiple' => true, 'value' => $value]);
     if ($hasModel) {
         $output = Html::activeListBox($this->model, $this->attribute, $this->items, $options);
     } else {
         $output = Html::listBox($this->name, $this->value, $this->items, $options);
     }
     $clientOptions = array_merge(['filter' => $this->filter, 'multiple' => $this->multiple, 'multipleWidth' => $this->multipleWidth], $this->clientOptions);
     if (!array_key_exists('placeholder', $clientOptions) && array_key_exists('placeholder', $options)) {
         $clientOptions['placeholder'] = $options['placeholder'];
     }
     $js = 'jQuery(\'#' . $inputId . '\').multipleSelect(' . Json::htmlEncode($clientOptions) . ');';
     if (Yii::$app->getRequest()->getIsAjax()) {
         $output .= Html::script($js);
     } else {
         $view = $this->getView();
         MultipleSelectAsset::register($view);
         $view->registerJs($js);
     }
     return $output;
 }
开发者ID:heartshare,项目名称:yii2-jquery-multiple-select,代码行数:34,代码来源:MultipleSelect.php

示例3: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     try {
         $this->_initAndValidate();
         $valueArray = [];
         $trees = [];
         $valueSingle = "";
         $select = "";
         $singleInput = "";
         if (in_array($this->mode, [self::MOD_COMBO, self::MOD_MULTI])) {
             $valueArray = Html::getAttributeValue($this->model, $this->attribute);
             $select = Html::activeListBox($this->model, $this->attribute, ['16' => "16"], ['multiple' => true, 'class' => 'sx-controll-element', 'style' => 'display: none;']);
             $trees = Tree::find()->where(['id' => $valueArray])->all();
         }
         if (in_array($this->mode, [self::MOD_COMBO, self::MOD_SINGLE])) {
             $singleInput = Html::activeInput("hidden", $this->model, $this->attributeSingle, ['class' => 'sx-single']);
             $valueSingle = Html::getAttributeValue($this->model, $this->attributeSingle);
         }
         $src = UrlHelper::construct('/cms/admin-tree')->set('mode', $this->mode)->set('s', $valueArray)->setSystemParam(Module::SYSTEM_QUERY_EMPTY_LAYOUT, 'true')->setSystemParam(Module::SYSTEM_QUERY_NO_ACTIONS_MODEL, 'true')->enableAdmin()->toString();
         $id = "sx-id-" . md5(serialize([$this->clientOptions, $this->mode, $this->attributeMulti, $this->attributeSingle]));
         $selected = [];
         foreach ($trees as $tree) {
             $selected[] = $tree->id;
         }
         return $this->render('widget', ['widget' => $this, 'id' => $id, 'select' => $select, 'src' => $src, 'valueSingle' => $valueSingle, 'singleInput' => $singleInput, 'clientOptions' => Json::encode(['src' => $src, 'name' => $id, 'id' => $id, 'selected' => $selected, 'valueSingle' => $valueSingle])]);
         //$this->registerClientScript();
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }
开发者ID:Liv1020,项目名称:cms,代码行数:33,代码来源:SelectTree.php

示例4: init

 /**
  * Initializes the widget.
  * @throws \yii\base\InvalidConfigException
  */
 public function init()
 {
     parent::init();
     foreach ($this->items as $value => $item) {
         if (is_string($item)) {
             throw new InvalidConfigException("Items cannot be of type string.");
         }
         $item['options'] = ['value' => $value];
     }
     if ($this->hasModel()) {
         $value = Html::getAttributeValue($this->model, $this->attribute);
         if (!empty($value)) {
             $defaultText = $value;
         }
     } else {
         if (!empty($this->value)) {
             $defaultText = $this->value;
         }
     }
     if (empty($defaultText)) {
         $defaultText = Yii::t('dosamigos/semantic/selection', 'Select...');
     }
     $this->defaultText = $this->encodeDefaultText ? Html::encode($defaultText) : $defaultText;
     Html::addCssClass($this->options, 'selection');
 }
开发者ID:2amigos,项目名称:yii2-semantic-ui,代码行数:29,代码来源:Selection.php

示例5: init

 public function init()
 {
     parent::init();
     $this->_inputStr = '<div class="form-group">';
     if ($this->hasModel()) {
         $this->_inputStr .= Html::activeLabel($this->model, $this->attribute);
     } else {
         $this->_inputStr .= Html::label($this->name);
     }
     $this->_inputStr .= '<div id="' . Html::encode($this->name) . '" class="input-group date">';
     if ($this->hasModel()) {
         $value = Html::getAttributeValue($this->model, $this->attribute);
     } else {
         $value = $this->value;
     }
     if ($value !== null) {
         $value = Yii::$app->formatter->asDatetime($value);
     }
     $options = $this->options;
     $options['class'] = 'form-control';
     //$options['readonly'] = '';
     $options['value'] = $value;
     if ($this->hasModel()) {
         $this->_inputStr .= Html::activeTextInput($this->model, $this->attribute, $options);
     } else {
         $this->_inputStr .= Html::textInput($this->name, $this->value, $options);
     }
     $this->_inputStr .= '<span class="input-group-addon">
                                     <span class="glyphicon-calendar glyphicon"></span>
                                 </span>
                             </div>
                             </div>
                             ';
 }
开发者ID:Penton,项目名称:MoBlog,代码行数:34,代码来源:BootstrapDatetimePicker.php

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

示例7: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     $this->_msgCat = 'kvcolor';
     if (!isset($this->type)) {
         $this->type = $this->useNative ? 'color' : 'text';
     }
     $this->width = '60px';
     $this->initI18N(__DIR__);
     if (empty($this->html5Container['id'])) {
         $this->html5Container['id'] = $this->options['id'] . '-cont';
     }
     if ($this->type === 'text') {
         Html::addCssStyle($this->html5Options, 'display:none');
         if ($this->pluginLoading) {
             Html::addCssClass($this->html5Container, 'kv-center-loading');
         }
     }
     $this->html5Options['value'] = $this->hasModel() ? Html::getAttributeValue($this->model, $this->attribute) : $this->value;
     if (substr($this->language, 0, 2) !== 'en') {
         $this->_defaultOptions += ['cancelText' => Yii::t('kvcolor', 'cancel'), 'chooseText' => Yii::t('kvcolor', 'choose'), 'clearText' => Yii::t('kvcolor', 'Clear Color Selection'), 'noColorSelectedText' => Yii::t('kvcolor', 'No Color Selected'), 'togglePaletteMoreText' => Yii::t('kvcolor', 'more'), 'togglePaletteLessText' => Yii::t('kvcolor', 'less')];
     }
     Html::addCssClass($this->containerOptions, 'spectrum-group');
     Html::addCssClass($this->html5Options, 'spectrum-source');
     Html::addCssClass($this->options, 'spectrum-input');
     if (!$this->useNative) {
         Html::addCssClass($this->html5Container, 'input-group-sp');
         $this->pluginOptions = array_replace_recursive($this->_defaultOptions, $this->pluginOptions);
     }
     $this->initInput();
     $this->registerColorInput();
 }
开发者ID:ICHydro,项目名称:anaconda,代码行数:34,代码来源:ColorInput.php

示例8: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     $inputId = $this->options['id'];
     $hasModel = $this->hasModel();
     if (array_key_exists('value', $this->options)) {
         $value = $this->options['value'];
     } elseif ($hasModel) {
         $value = Html::getAttributeValue($this->model, $this->attribute);
     } else {
         $value = $this->value;
     }
     $options = array_merge($this->options, ['value' => $value]);
     if ($hasModel) {
         $output = Html::activeTextInput($this->model, $this->attribute, $options);
     } else {
         $output = Html::textInput($this->name, $this->value, $options);
     }
     if (!is_null($this->alias)) {
         $clientOptions = array_merge($this->clientOptions, ['alias' => $this->alias]);
     } else {
         $clientOptions = array_merge($this->clientOptions, ['mask' => $this->mask]);
     }
     if (!array_key_exists('placeholder', $clientOptions) && array_key_exists('placeholder', $options)) {
         $clientOptions['placeholder'] = $options['placeholder'];
     }
     $js = 'jQuery(\'#' . $inputId . '\').inputmask(' . Json::htmlEncode($clientOptions) . ');';
     if (Yii::$app->getRequest()->getIsAjax()) {
         $output .= Html::script($js);
     } else {
         $view = $this->getView();
         InputMaskAsset::register($view);
         $view->registerJs($js);
     }
     return $output;
 }
开发者ID:heartshare,项目名称:yii2-jquery-input-mask,代码行数:38,代码来源:InputMask.php

示例9: run

 public function run()
 {
     if (!$this->hasModel() || !$this->attribute) {
         throw new InvalidConfigException('Fuzzydate DatePicker must have model and attribute.');
     }
     $view = $this->getView();
     $asset = new DatePickerAsset();
     $asset->register($view);
     $view->registerJs("fuzzyReg();");
     $id = Html::getInputId($this->model, $this->attribute);
     $val = Html::getAttributeValue($this->model, $this->attribute);
     if ($val && is_array($val)) {
         $y = $val['y'];
         if ($y) {
             $m = $val['m'];
             if (!$m) {
                 $m = 'null';
             }
             $d = $val['d'];
             if (!$d) {
                 $d = 'null';
             }
             // Call this after initializing jQuery-objects
             $view->registerJs("fuzzySet('{$id}', {$y}, {$m}, {$d});", View::POS_LOAD);
         }
     }
     if (!$this->minYear) {
         $this->minYear = date('Y');
     }
     if (!$this->maxYear) {
         $this->maxYear = date('Y');
     }
     $widget = $this->getViewPath() . DIRECTORY_SEPARATOR . 'datePicker.php';
     echo $view->renderFile($widget, ['widget' => $this]);
 }
开发者ID:sjaakp,项目名称:yii2-fuzzydate,代码行数:35,代码来源:DatePicker.php

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

示例11: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     $this->clientOptions = array_merge_recursive(self::$defaultSettings, $this->clientOptions);
     $this->clientOptions['extended_valid_elements'] = implode(',', $this->clientOptions['extended_valid_elements']);
     if ($this->hasModel()) {
         $this->options['name'] = isset($this->options['name']) ? $this->options['name'] : Html::getInputName($this->model, $this->attribute);
         if (isset($this->options['value'])) {
             $value = $this->options['value'];
             unset($this->options['value']);
         } else {
             $value = Html::getAttributeValue($this->model, $this->attribute);
         }
         if (!array_key_exists('id', $this->options)) {
             $this->options['id'] = Html::getInputId($this->model, $this->attribute);
         }
     } else {
         $options['name'] = $this->name;
         $value = $this->value;
     }
     if (!isset($this->options['class'])) {
         $this->options['class'] = 'tinymce';
     }
     echo Html::tag('div', $value, $this->options);
     $this->registerClientScript();
 }
开发者ID:comradepashka,项目名称:yii2-tinymce,代码行数:28,代码来源:TinyMce.php

示例12: composeFilterState

 /**
  * @param $column
  * @return void
  */
 public function composeFilterState($column)
 {
     if (!preg_match('/(^|.*\\])([\\w\\.]+)(\\[.*|$)/', $column->attribute, $matches)) {
         throw new InvalidParamException('Attribute name must contain word characters only.');
     }
     $formName = $this->_gridView->filterModel->formName();
     $value = Html::getAttributeValue($this->_gridView->filterModel, $column->attribute);
     $keys = [$formName];
     if ($matches[1] === '') {
         $keys[] = $matches[2];
         if ($matches[3] !== '') {
             $keys[] = $matches[3];
         }
     } else {
         $keys[] = $matches[1];
         $keys[] = $matches[2];
         if ($matches[3] !== '') {
             $keys[] = $matches[3];
         }
     }
     $s =& $this->_state;
     foreach ($keys as $key) {
         if (end($keys) === $key) {
             is_array($s) and $s[$key] = $value;
         } else {
             $s[$key] = isset($s[$key]) ? $s[$key] : [];
             $s =& $s[$key];
         }
     }
 }
开发者ID:tranch-xiao,项目名称:yii2-grid-view-state,代码行数:34,代码来源:FilterStateBehavior.php

示例13: run

 public function run()
 {
     call_user_func([$this, 'register' . ucfirst($this->driver) . 'ClientJs']);
     $value = $this->hasModel() ? Html::getAttributeValue($this->model, $this->attribute) : $this->value;
     // 已经传过图片,显示预览图
     $image = $value ? Html::img(strpos($value, 'http:') === false ? \Yii::getAlias('@static') . '/' . $value : $value, ['width' => $this->options['previewWidth'], 'height' => $this->options['previewHeight']]) : '';
     return $this->render('main', ['boxId' => $this->options['boxId'], 'hiddenInput' => $this->hiddenInput, 'image' => $image]);
 }
开发者ID:yidashi,项目名称:yii2-webuploader,代码行数:8,代码来源:Webuploader.php

示例14: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     $web = rtrim(\Yii::getAlias('@static'), '/');
     $value = $this->hasModel() ? Html::getAttributeValue($this->model, $this->attribute) : $this->value;
     $image = $value ? Html::img(strpos($value, 'http:') === false ? \Yii::getAlias('@static') . '/' . $value : $value, ['width' => $this->options['previewWidth'], 'height' => $this->options['previewHeight']]) : '';
     $this->registerClientScript();
     return $this->render('cropper', ['options' => $this->options, 'image' => $image, 'server' => $this->server, 'hiddenInput' => $this->hiddenInput, 'web' => $web]);
 }
开发者ID:yidashi,项目名称:yii2-webuploader,代码行数:11,代码来源:Cropper.php

示例15: run

 public function run()
 {
     $this->tagOptions['data-input'] = '#' . $this->options['id'];
     $this->options['style'] = 'display: none;';
     $this->registerClientScripts();
     echo Html::tag('div', Html::getAttributeValue($this->model, $this->attribute), $this->tagOptions);
     echo Html::activeTextarea($this->model, $this->attribute, $this->options);
 }
开发者ID:kotchuprik,项目名称:yii2-medium-widget,代码行数:8,代码来源:Widget.php


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