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


PHP Html::getInputName方法代码示例

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


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

示例1: renderInput

 /**
  * 
  * @param \yii\db\ActiveRecord $model
  * @param integer $index
  * @return type
  */
 protected function renderInput($model, $index)
 {
     if ($this->inputOptions instanceof \Closure) {
         $options = call_user_func($this->inputOptions, $model, $index);
     } else {
         $options = $this->inputOptions;
     }
     $options['data-attribute'] = $this->attribute;
     if ($this->_isList) {
         if ($this->inputItems instanceof \Closure) {
             $items = call_user_func($this->inputItems, $model, $index);
         } else {
             $items = $this->inputItems;
         }
         if ($model->hasAttribute($this->attribute)) {
             return call_user_func(['yii\\helpers\\Html', 'active' . $this->inputType], $model, "[{$index}]{$this->attribute}", $items, $options);
         } else {
             $name = Html::getInputName($model, "[{$index}]{$this->attribute}");
             $value = ArrayHelper::remove($options, 'value');
             return call_user_func(['yii\\helpers\\Html', $this->inputType], $name, $value, $items, $options);
         }
     } else {
         if ($model->hasAttribute($this->attribute)) {
             return call_user_func(['yii\\helpers\\Html', 'active' . $this->inputType], $model, "[{$index}]{$this->attribute}", $options);
         } else {
             $name = Html::getInputName($model, "[{$index}]{$this->attribute}");
             $value = ArrayHelper::remove($options, 'value');
             return call_user_func(['yii\\helpers\\Html', $this->inputType], $name, $value, $options);
         }
     }
 }
开发者ID:sangkilsoft,项目名称:sangkilbiz-3,代码行数:37,代码来源:InputColumn.php

示例2: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     $jsOptions = ['clientOptions' => $this->clientOptions];
     $this->options['id'] = 'input-id';
     if ($this->hasModel()) {
         echo Html::activeInput('file', $this->model, $this->attribute, $this->options);
         echo Html::img('#', ['id' => 'cropper-box']);
         echo Html::button('Crop', ['id' => 'cropImage']);
         $input_name = Html::getInputName($this->model, $this->attribute);
         $input_id = Html::getInputId($this->model, $this->attribute);
         echo Html::hiddenInput($input_name . '[file]', '', ['id' => $input_id . '_image']);
         $jsOptions['model'] = $this->model;
         $jsOptions['attribute'] = $this->attribute;
     } else {
         echo Html::fileInput($this->name, $this->value, $this->options);
         echo Html::img('#', ['id' => 'cropper-box']);
         echo Html::button('Crop', ['id' => 'cropImage']);
     }
     if ($this->uploadUrl) {
         $this->uploadUrl = \Yii::getAlias($this->uploadUrl);
     }
     $jsOptions['uploadUrl'] = $this->uploadUrl;
     $jsOptions['uploadCroppedUrl'] = $this->uploadCroppedUrl;
     $jsOptions['changeUrl'] = $this->changeUrl;
     $jsOptions['name'] = $this->name;
     $jsOptions['aspectRatio'] = $this->aspectRatio;
     $this->registerPlugin($jsOptions);
 }
开发者ID:servsol,项目名称:yii2-cropper,代码行数:31,代码来源:Cropper.php

示例3: run

 public function run()
 {
     if ($this->model === null) {
         $inputId = $this->getId();
     } else {
         if ($this->getId(false) === null) {
             $inputId = Html::getInputId($this->model, $this->attribute);
             $this->setId($inputId);
         } else {
             $inputId = $this->getId();
         }
     }
     $widgetId = $inputId . '-map';
     if ($this->name === null) {
         $inputName = $this->model === null ? null : Html::getInputName($this->model, $this->attribute);
     } else {
         $inputName = $this->name;
     }
     if ($this->enableSearchBox === true) {
         $this->_renderSearchBox();
     }
     // render attribute as hidden input
     if ($this->model === null) {
         echo Html::hiddenInput($inputName, $this->value, ['id' => $inputId, 'name' => $inputName]);
     } else {
         echo Html::activeHiddenInput($this->model, $this->attribute, ['id' => $inputId, 'name' => $inputName]);
     }
     $this->_registerOnChangedEvent($this->id);
     $this->_registerOnInitializedEvent();
     $this->_setClientLocation();
     $widgetOptions = $this->options;
     unset($widgetOptions['id']);
     echo LocationPickerWidget::widget(['id' => $widgetId, 'key' => $this->key, 'options' => $widgetOptions, 'clientOptions' => $this->clientOptions, 'clientEvents' => $this->clientEvents]);
 }
开发者ID:pigochu,项目名称:yii2-jquery-locationpicker,代码行数:34,代码来源:CoordinatesPicker.php

示例4: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     Asset::register($this->view);
     $inputId = Html::getInputId($this->model, $this->attribute);
     $field = $this->render('_field', ['fieldClass' => 'field-' . $inputId, 'inputId' => $inputId, 'inputName' => Html::getInputName($this->model, $this->attribute) . '[]', 'inputLabel' => $this->model->getAttributeLabel($this->attribute)]);
     $options = Json::htmlEncode(['field' => $field, 'firstAddTogglerText' => 'добавить свою категорию', 'addTogglerText' => 'добавить ещё', 'values' => $this->model->{$this->attribute}]);
     $this->view->registerJs('jQuery("#' . $this->id . '").kategoriiSlushatelejInputFields(' . $options . ');');
     return Html::tag('div', $this->renderFirstToggler(), ['id' => $this->id, 'class' => 'kategorii-slushatelej-input-fields']);
 }
开发者ID:tsyrya,项目名称:mybriop,代码行数:12,代码来源:KategoriiSlushatelejInputFields.php

示例5: getStorage

 /**
  * @return EmbeddedDocument
  */
 public function getStorage()
 {
     if (empty($this->_storage)) {
         $this->_storage = $this->createEmbedded((array) $this->owner->{$this->attribute}, false, ['formName' => $this->setFormName ? Html::getInputName($this->owner, $this->fakeAttribute) : null]);
     }
     return $this->_storage;
 }
开发者ID:ske,项目名称:yii2-mongodb-embedded,代码行数:10,代码来源:EmbedsOneBehavior.php

示例6: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     if ($this->hasModel()) {
         $name = Html::getInputName($this->model, $this->attribute);
         $value = null;
         if (is_array($this->model->{$this->attribute})) {
             $value = StringHelper::base64EncodeUrl(serialize((array) $this->model->{$this->attribute}));
         } else {
             if (is_string($this->model->{$this->attribute})) {
                 $value = $this->model->{$this->attribute};
             }
         }
         $this->options['id'] = Html::getInputId($this->model, $this->attribute);
         //$element = Html::activeHiddenInput($this->model, $this->attribute, $this->options);
         $element = Html::hiddenInput($name, $value, $this->options);
     } else {
         $element = Html::hiddenInput($this->name, $this->value, $this->options);
     }
     $this->registerPlugin();
     $this->clientOptions['componentSelectId'] = $this->componentSelectId;
     $this->clientOptions['componentSettingsId'] = Html::getInputId($this->model, $this->attribute);
     $this->clientOptions['id'] = $this->id;
     $this->clientOptions['backend'] = UrlHelper::construct('/cms/admin-universal-component-settings/index')->setSystemParam(Module::SYSTEM_QUERY_EMPTY_LAYOUT, 'true')->enableAdmin()->toString();
     return $this->render('element', ['widget' => $this, 'element' => $element]);
 }
开发者ID:skeeks-cms,项目名称:cms,代码行数:28,代码来源:ComponentSettingsWidget.php

示例7: run

 public function run()
 {
     if (empty($this->name) && (!empty($this->model) && !empty($this->attribute))) {
         $this->name = Html::getInputName($this->model, $this->attribute);
     }
     if (empty($this->url)) {
         $this->url = Url::toRoute(['site/upload']);
     }
     $options = ['url' => $this->url, 'paramName' => $this->name, 'params' => []];
     if (Yii::$app->request->enableCsrfValidation) {
         $options['params'][Yii::$app->request->csrfParam] = Yii::$app->request->getCsrfToken();
     }
     if (!empty($this->message)) {
         $message = Html::tag('div', $this->message, $this->messageOptions);
     } else {
         $message = '';
     }
     $this->htmlOptions['id'] = $this->id;
     $this->options = ArrayHelper::merge($this->options, $options);
     echo Html::tag('div', $message, $this->htmlOptions);
     $this->registerAssets();
     $this->createDropzone();
     foreach ($this->eventHandlers as $event => $handler) {
         $handler = new \yii\web\JsExpression($handler);
         $this->getView()->registerJs($this->dropzoneName . ".on('{$event}', {$handler})");
     }
     $this->addFiles($this->storedFiles);
     $this->decrementMaxFiles(count($this->storedFiles));
     if ($this->sortable) {
         $options = Json::encode($this->sortableOptions);
         $this->getView()->registerJs("jQuery('#{$this->id}').sortable(" . $options . ");");
     }
 }
开发者ID:rumes,项目名称:yii2-dropzone,代码行数:33,代码来源:DropZone.php

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

示例9: run

 public function run()
 {
     if ($this->hasModel()) {
         $replace['{input}'] = Html::activeHiddenInput($this->model, $this->attribute, $this->options);
         $attributeId = Html::getInputId($this->model, $this->attribute);
         $id = Html::getInputId($this->model, 'hydra_' . $this->attribute);
         $name = Html::getInputName($this->model, 'hydra_' . $this->attribute);
         $this->value = $this->model[$this->attribute];
     } else {
         $replace['{input}'] = Html::hiddenInput($this->name, $this->value, $this->options);
         $name = $id = 'hydra_' . $this->name;
         $attributeId = $this->name;
     }
     $fileInputName = empty($this->fileInputName) ? $name : $this->fileInputName;
     $replace['{preview}'] = 'Файл еще не загружен';
     if (!empty($this->value)) {
         $replace['{preview}'] = $this->value;
         $extension = Yii::$app->hydra->getExtension($this->value);
         if (Yii::$app->hydra->isImage($extension)) {
             $replace['{preview}'] = Html::img(Yii::$app->hydra->getCacheUrl($this->value, $this->resolution), ['id' => $id . '_image']);
         }
         $replace['{reset-button}'] = Html::tag($this->resetButton['tag'], $this->resetButton['label'], ArrayHelper::merge(['onClick' => '$("#' . $attributeId . '").val("");$("#' . $id . '_image' . '").remove();$(this).remove();'], $this->resetButton['options']));
     }
     $replace['{input}'] .= Html::fileInput($fileInputName, null, ArrayHelper::merge(['id' => $id], $this->fileInput['options']));
     return strtr($this->template, $replace);
 }
开发者ID:zabachok,项目名称:yii2-hydra,代码行数:26,代码来源:FileInput.php

示例10: renderDataCellContent

 /**
  * @inheritdoc
  */
 protected function renderDataCellContent($model, $key, $index)
 {
     if (isset($this->htmlOptions['class'])) {
         $this->htmlOptions['class'] .= 'editableCell form-control';
     } else {
         $this->htmlOptions['class'] = 'editableCell form-control';
     }
     // We need to number the submit attributes because data attribute is not case sensitive
     $this->htmlOptions['data-submit-attributes'] = implode(',', $this->submitAttributes);
     $i = 0;
     foreach ($this->submitAttributes as $attribute) {
         $this->htmlOptions['data-attribute' . $i] = $model[$attribute];
         $i++;
     }
     $options = [];
     if (is_array($this->dropDownOptions)) {
         $options = $this->dropDownOptions;
     } else {
         $options = $model[$this->dropDownOptions];
     }
     $inputName = is_array($model) ? $this->attribute : Html::getInputName($model, $this->attribute);
     $readonly = $this->readonly;
     if (!is_bool($readonly)) {
         $readonly = call_user_func($this->readonly, $model, $key, $index, $this);
     }
     if ($readonly) {
         if (isset($options[$model[$this->attribute]])) {
             return $options[$model[$this->attribute]];
         }
         return $model[$this->attribute];
     }
     return Html::dropDownList($inputName, $model[$this->attribute], $options, $this->htmlOptions);
 }
开发者ID:SimonBaeumer,项目名称:humhub,代码行数:36,代码来源:DropDownGridColumn.php

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

示例12: init

 /**
  *
  */
 public function init()
 {
     if (empty($this->parentName)) {
         throw new InvalidParamException('RelativeSelect2 $parentName must be set!');
     }
     if (empty($this->url)) {
         throw new InvalidParamException('RelativeSelect2 $url must be set!');
     }
     if ($this->parentModel instanceof Model) {
         $this->options['data']['select2-parent-name'] = Html::getInputName($this->parentModel, $this->parentName);
     } else {
         $this->options['data']['select2-parent-name'] = $this->hasModel() ? Html::getInputName($this->model, $this->parentName) : $this->parentName;
     }
     if (is_array($this->url)) {
         $this->url = Url::to($this->url);
     }
     $this->options['data']['select2-url'] = $this->url;
     if (!empty($this->model) && isset($this->model->{$this->attribute})) {
         if (is_array($this->model->{$this->attribute})) {
             $this->options['data']['select2-selected-items'] = implode(',', $this->model->{$this->attribute});
         } else {
             $this->options['data']['select2-selected-items'] = $this->model->{$this->attribute};
         }
     } else {
         $this->options['data']['select2-selected-items'] = $this->value;
     }
     parent::init();
     RelativeSelect2Asset::register($this->getView());
 }
开发者ID:platx,项目名称:yii2-relative-select2,代码行数:32,代码来源:RelativeSelect2.php

示例13: run

 public function run()
 {
     $id = $this->options['id'];
     $options = Json::htmlEncode($this->getClientOptions());
     $view = $this->getView();
     EditorGridViewAsset::register($view);
     $view->registerJs("jQuery('#{$id}').yiiGridView({$options});\$(document).off('change.yiiGridView keydown.yiiGridView');");
     if ($this->showOnEmpty || $this->dataProvider->getCount() > 0) {
         $content = preg_replace_callback("/{\\w+}/", function ($matches) {
             $content = $this->renderSection($matches[0]);
             return $content === false ? $matches[0] : $content;
         }, $this->layout);
     } else {
         $content = $this->renderEmpty();
     }
     $options = $this->options;
     $tag = ArrayHelper::remove($options, 'tag', 'div');
     echo Html::tag($tag, $content, $options);
     foreach ($this->columns as $column) {
         if (isset($column->attribute) && $column->editable) {
             $models = $this->dataProvider->getModels();
             if (($model = reset($models)) instanceof Model) {
                 $name = Html::getInputName($model, $column->attribute);
             } else {
                 $name = $column->attribute;
             }
             $attributeName = $column->attribute;
             $view->registerJs("\$('.{$attributeName}').editable({\n                    placement:'right',\n                    ajaxOptions: {\n                        type: 'GET',\n                        dataType: 'json'\n                    },\n                    success: function(response, newValue) {\n                        if(response.status=='success')\n                        {\n                            return jQuery('#{$this->options['id']}').yiiGridView('applyFilter');\n                        }\n                        else\n                        {\n                            return response.msg;\n                        }\n                    },\n                    params: function(rawParams) {\n                        var params = {};\n                        params['{$name}']=rawParams.value;\n                        params['pk']=rawParams.pk;\n                        return params;\n                    }\n                });");
         }
     }
 }
开发者ID:xuguoliangjj,项目名称:yiiblog,代码行数:31,代码来源:EditorGridView.php

示例14: init

 public function init()
 {
     if (empty($this->name)) {
         $this->name = $this->hasModel() ? Html::getInputName($this->model, $this->attribute) : $this->id;
     }
     if (empty($this->url)) {
         $this->url = Url::to(['index/upload']);
     }
     if (empty($this->id)) {
         $this->id = 'filePicker';
     }
     if (empty($this->template)) {
         $this->template = '<div id="' . $this->id . '">选择图片</div>';
     }
     $this->jsOptions['auto'] = isset($this->jsOptions['auto']) ? $this->jsOptions['auto'] : 'true';
     $this->jsOptions['swf'] = "'./asset/js/Uploader.swf'";
     $this->jsOptions['server'] = "'{$this->url}'";
     $this->jsOptions['pick'] = "{id:'#{$this->id}',multiple:false}";
     // $this->jsOptions['accept'] = "{
     // 					        title: 'Images',
     // 					        extensions: 'png,jpg,gif,doc,docx,xls,xlsx,pdf,txt',
     // 					        mimeTypes: 'application/zip,application/vnd.ms-excel,application/vnd.ms-powerpoint,image/*' +
     // 					            ',application/vnd.openxmlformats-officedocument.presentationml.presentation' +
     // 					            ',application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/msword' +
     // 					            ',application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,text/plain,application/x-rar-compressed'}";
     parent::init();
 }
开发者ID:fatjiong,项目名称:yii2-webuploader,代码行数:27,代码来源:WebUploader.php

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


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