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


PHP CHtml::activeName方法代码示例

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


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

示例1: init

 public function init()
 {
     $publishFolder = Yii::app()->assetManager->publish(dirname(__FILE__) . '/assets', false, -1, true);
     Yii::app()->clientScript->packages['_fileuploader'] = array('baseUrl' => $publishFolder, 'js' => array('js/vendor/jquery.ui.widget.js', 'js/jquery.iframe-transport.js', 'js/jquery.fileupload.js', 'js/jquery.fileupload-process.js'), 'css' => array('css/jquery.fileupload.css', 'css/jquery.fileupload-ui'), 'depends' => array('jquery', 'glyphicons'));
     Yii::app()->clientScript->registerPackage('_fileuploader');
     $this->render('index', array('controlId' => $this->id . '_uploader', 'uploadName' => $this->hasModel() ? CHtml::activeName($this->model, $this->attribute) : $this->name, 'uploadUrl' => CHtml::normalizeUrl($this->url), 'uploadId' => $this->hasModel() ? CHtml::activeId($this->model, $this->attribute) : "{$this->id}_{$this->name}", 'publicUrl' => $publishFolder));
 }
开发者ID:Diakonrus,项目名称:fastweb-yii,代码行数:7,代码来源:UFileUpload.php

示例2: testRun_FieldRendering

 /**
  * @param array $widgetOptions Widget options.
  * @covers ::run
  * @dataProvider testRun_FieldRendering_Provider
  */
 public function testRun_FieldRendering($widgetOptions)
 {
     $widget = $this->makeWidget();
     foreach ($widgetOptions as $option => $value) {
         $widget->{$option} = $value;
     }
     $widgetOutput = $this->runAndCapture($widget);
     $value = isset($widgetOptions['model']) ? $widgetOptions['model']->login : $widgetOptions['value'];
     if (isset($widgetOptions['model'])) {
         $name = CHtml::activeName($widgetOptions['model'], $widgetOptions['attribute']);
     } elseif (isset($widgetOptions['htmlOptions']['name'])) {
         $name = $widgetOptions['htmlOptions']['name'];
     } else {
         $name = $widgetOptions['name'];
     }
     if (isset($widgetOptions['model'])) {
         $id = CHtml::activeId($widgetOptions['model'], $widgetOptions['attribute']);
     } elseif (isset($widgetOptions['htmlOptions']['id'])) {
         $id = $widgetOptions['htmlOptions']['id'];
     } else {
         $id = CHtml::getIdByName($widgetOptions['name']);
     }
     if ($widgetOptions['type'] == Select2::TYPE_TEXT) {
         $this->assertTag(['tag' => 'input', 'attributes' => ['type' => 'text', 'name' => $name, 'id' => $id, 'value' => $value, 'class' => 'baz']], $widgetOutput);
     } else {
         $this->assertTag(['tag' => 'select', 'attributes' => ['name' => $name, 'id' => $id, 'class' => 'baz']], $widgetOutput);
         $this->assertTag(['tag' => 'option', 'parent' => ['tag' => 'select'], 'attributes' => ['selected' => 'selected', 'value' => $value]], $widgetOutput);
     }
 }
开发者ID:intersvyaz,项目名称:yii-select2,代码行数:34,代码来源:Select2Test.php

示例3: init

 public function init()
 {
     $this->options = array_merge($this->options, array('autoFocus' => true, 'showAnim' => 'fold'));
     $this->autoCompleteHtmlOptions = array_merge($this->autoCompleteHtmlOptions, array('name' => $this->returnId ? str_replace('[', '_disabled[', CHtml::activeName($this->model, $this->attribute)) : CHtml::activeName($this->model, $this->attribute), 'id' => CHtml::activeId($this->model, $this->attribute), 'value' => $this->value));
     if ($this->returnId) {
         $this->options = array_merge($this->options, array('select' => "js:function(event,ui){\n\t\t\t\t\t\t\t\t\$('input#'+\$(this).attr('id')+'[type=hidden]').attr('value',ui.item.id);\n\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}"));
     }
 }
开发者ID:aantonw,项目名称:dcourier.system,代码行数:8,代码来源:CSuggest.php

示例4: getExtProducts

 public static function getExtProducts($shipment)
 {
     $result = array();
     $products = self::model()->findAll();
     foreach ($products as $product) {
         array_push($result, array('boxLabel' => $product->name, 'name' => CHtml::activeName($shipment, 'service_type'), 'id' => str_replace(" ", "-", $product->name), 'inputValue' => $product->name, 'width' => 150, 'checked' => $shipment->service_type == $product->name));
     }
     return CJSON::encode($result);
 }
开发者ID:aantonw,项目名称:dcourier.system,代码行数:9,代码来源:Product.php

示例5: getName

 /**
  * @param $attribute
  * @return string
  */
 public function getName($attribute)
 {
     $name = $attribute;
     if ($this->model instanceof CActiveRecord && isset($this->model->{$attribute})) {
         $name = CHtml::activeName($this->model, $attribute);
     } elseif ($this->prefixName) {
         $name = $this->prefixName . "[{$attribute}]";
     }
     return $name;
 }
开发者ID:bookin,项目名称:yii-choose-location,代码行数:14,代码来源:Choose.php

示例6: renderDataCellContent

 protected function renderDataCellContent($row, $data)
 {
     $model = CustomerDiscount::model()->findByAttributes(array('customer_id' => $this->customer_id, 'service_id' => $data->id));
     if (!$model instanceof CustomerDiscount) {
         $model = new CustomerDiscount();
     }
     $options = $this->checkBoxHtmlOptions;
     $options['name'] = str_replace('CustomerDiscount', 'CustomerDiscount[' . $row . ']', CHtml::activeName($model, $this->forAttribute));
     $options['class'] = $this->id;
     echo CHtml::activeCheckBox($model, $this->forAttribute, $options);
 }
开发者ID:aantonw,项目名称:dcourier.system,代码行数:11,代码来源:CFCheckBoxColumn.php

示例7: toRequestParams

 public function toRequestParams()
 {
     $attributes = array('objectId', 'instanceId', 'parameterId', 'tmpId');
     $result = array();
     foreach ($attributes as $attrName) {
         if ($this->{$attrName} === null) {
             continue;
         }
         $result[CHtml::activeName($this, $attrName)] = $this->{$attrName};
     }
     return $result;
 }
开发者ID:Cranky4,项目名称:npfs,代码行数:12,代码来源:FileUploadForm.php

示例8: run

 /**
  * Runs the widget.
  */
 public function run()
 {
     Yii::import("sys.models.SysModules");
     $module = Yii::app()->controller->module->id;
     $sysModule = SysModules::model()->find(TUtil::qc('code') . "=:code", array(":code" => $module));
     if ($sysModule != null && $sysModule->enable_attachment == 0) {
         return;
     }
     $id = $this->id . '-file';
     $containerId = $this->id . '-container';
     $label = '从本地选择';
     if ($this->hasModel()) {
         $name = CHtml::activeName($this->model, $this->attribute) . '[]';
         $attributes = array('name' => $name, 'id' => $id, 'hideFocus' => true);
         if (isset($this->htmlOptions['accept'])) {
             $attributes['accept'] = $this->htmlOptions['accept'];
         }
         if (isset($this->htmlOptions['maxlength'])) {
             $attributes['maxlength'] = $this->htmlOptions['maxlength'];
         }
         if (isset($this->htmlOptions['multiple'])) {
             $attributes['multiple'] = $this->htmlOptions['multiple'];
         }
         if ($this->form) {
             $label .= $this->form->fileField($this->model, $this->attribute, $attributes);
         } else {
             $label .= CHtml::activeFileField($this->model, $this->attribute, $attributes);
         }
     }
     $this->controller->widget('bootstrap.widgets.TbButton', array('type' => $this->selectorType, 'label' => $label, 'icon' => 'storage', 'encodeLabel' => false, 'htmlOptions' => $this->htmlOptions));
     if ($this->enableFileFolder == true) {
         echo "   ";
         $this->controller->widget('bootstrap.widgets.TbButton', array('type' => $this->selectorType, 'label' => '从文件柜选择', 'buttonType' => 'button', 'icon' => 'folder', 'id' => $id . '_btn'));
     }
     if ($this->enableInsertPicture == true) {
         echo "   ";
         $this->widget('core.widgets.TPictureSelector', array('model' => $this->model, 'attribute' => $this->attribute . "_picture"));
     }
     if ($this->enableFileFolder == true) {
         echo "<div id='SelFileDiv'></div>";
     }
     echo CHtml::tag('div', array('id' => $containerId), '', true);
     if ($this->enableFileFolder == true) {
         echo CHtml::hiddenField('Sel_ATTACHMENT_ID', '', array('id' => 'Sel_ATTACHMENT_ID'));
         echo CHtml::hiddenField('Sel_ATTACHMENT_NAME', '', array('id' => 'Sel_ATTACHMENT_NAME'));
         $this->registerClientScript($id);
     }
     Yii::app()->bootstrap->registerAssetCss('bootstrap-file-selector.css');
     $cs = Yii::app()->getClientScript();
     $cs->registerCoreScript('multifile');
     $cs->registerScript(__CLASS__ . '#' . $this->id, "\n\$('#{$id}').MultiFile(" . CJavaScript::encode($this->options) . ")");
 }
开发者ID:GsHatRed,项目名称:Yiitest,代码行数:55,代码来源:TbFileSelector.php

示例9: run

    public function run()
    {
        $model = $this->model;
        $cities = $this->cities;
        $locations = $model->locations;
        if (empty($locations)) {
            $location = new CompetitionLocation();
            $locations = array($location->attributes);
        }
        //tab
        echo CHtml::openTag('ul', array('class' => 'nav nav-tabs', 'role' => 'tablist'));
        foreach ($locations as $key => $location) {
            $index = $key + 1;
            echo CHtml::tag('li', array('class' => $key == 0 ? 'active' : ''), CHtml::tag('a', array('href' => '#location-' . $index, 'role' => 'tab', 'data-toggle' => 'tab'), '地址' . $index . ($key == 0 ? '<span class="required">*</span></a>' : '')));
        }
        echo '<li><a id="addLocation"><i class="fa fa-plus"></i> 添加</a></li>';
        echo CHtml::closeTag('ul');
        echo '<div class="text-danger col-lg-12">地址1必填,除非多地点比赛,否则请只填写一个地址,留空即可删去多余地址。</div>';
        //tab content
        echo CHtml::openTag('div', array('class' => 'tab-content locations'));
        foreach ($locations as $key => $location) {
            $index = $key + 1;
            echo CHtml::openTag('div', array('class' => 'tab-pane location' . ($key == 0 ? ' active' : ''), 'id' => 'location-' . $index));
            echo Html::formGroup($model, 'locations[province_id][]', array('class' => 'col-lg-6'), CHtml::label('省份', false), CHtml::dropDownList(CHtml::activeName($model, 'locations[province_id][]'), $location['province_id'], Region::getProvinces(false), array('class' => 'form-control province', 'prompt' => '')), CHtml::error($model, 'locations.province_id.' . $key, array('class' => 'text-danger')));
            echo Html::formGroup($model, 'locations[city_id][]', array('class' => 'col-lg-6'), CHtml::label('城市', false), CHtml::dropDownList(CHtml::activeName($model, 'locations[city_id][]'), $location['city_id'], isset($cities[$location['province_id']]) ? $cities[$location['province_id']] : array(), array('class' => 'form-control city', 'prompt' => '')), CHtml::error($model, 'locations.city_id.' . $key, array('class' => 'text-danger')));
            echo Html::formGroup($model, 'locations[venue_zh][]', array('class' => 'col-lg-12'), CHtml::label('中文地址', false), CHtml::textField(CHtml::activeName($model, 'locations[venue_zh][]'), $location['venue_zh'], array('class' => 'form-control')), CHtml::error($model, 'locations.venue_zh.' . $key, array('class' => 'text-danger')));
            echo Html::formGroup($model, 'locations[venue][]', array('class' => 'col-lg-12'), CHtml::label('英文地址', false), CHtml::textField(CHtml::activeName($model, 'locations[venue][]'), $location['venue'], array('class' => 'form-control')), CHtml::error($model, 'locations.venue.' . $key, array('class' => 'text-danger')));
            echo CHtml::closeTag('div');
        }
        echo CHtml::closeTag('div');
        Yii::app()->clientScript->registerScript('MultiLocations', <<<EOT
  \$(document).on('click', '#addLocation', function() {
    var location = \$('.location:last').clone();
    var index = \$('.location').length + 1;
    var tab = \$('<a role="tab" data-toggle="tab">').attr('href', '#location-' + index).text('地址' + index);
    location.appendTo(\$('.locations'));
    location.find('.province').val('').trigger('change');
    location.find('input').val('');
    location.attr('id', 'location-' + index).removeClass('active');
    \$('<li>').append(
      tab
    ).insertBefore(\$('#addLocation').parent());
    tab.tab('show');
  });
EOT
);
    }
开发者ID:sunshy360,项目名称:cubingchina,代码行数:47,代码来源:MultiLocations.php

示例10: run

 /**
  * Create a div and the appropriate Javascript to make the div into the file upload area
  */
 public function run()
 {
     if (!$this->url || $this->url == '') {
         $this->url = Yii::app()->createUrl('site/upload');
     }
     echo CHtml::openTag('div', array('class' => 'dropzone', 'id' => 'fileup'));
     echo CHtml::closeTag('div');
     if (!$this->name && ($this->model && $this->attribute) && $this->model instanceof CModel) {
         $this->name = CHtml::activeName($this->model, $this->attribute);
     }
     $this->mimeTypes = CJavaScript::encode($this->mimeTypes);
     $options = CMap::mergeArray(array('url' => $this->url, 'parallelUploads' => 1, 'paramName' => $this->name, 'accept' => "js:function(file, done){if(jQuery.inArray(file.type,{$this->mimeTypes}) == -1 ){done('File type not allowed.');}else{done();}}", 'init' => "js:function(){this.on('success',function(file){{$this->onSuccess}});}"), $this->options);
     $options = CJavaScript::encode($options);
     $script = "Dropzone.options.fileup = {$options}";
     $this->registerAssets();
     Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $this->getId(), $script, CClientScript::POS_END);
 }
开发者ID:arsenaldima,项目名称:poslednaaVersia,代码行数:20,代码来源:EDropzone.php

示例11: init

 public function init()
 {
     if (!$this->url) {
         $this->url = Yii::app()->createUrl('site/upload');
     }
     if (!$this->name && $this->model instanceof CModel && $this->attribute) {
         $this->name = CHtml::activeName($this->model, $this->attribute);
     }
     if (empty($this->htmlOptions['id'])) {
         $this->htmlOptions['id'] = $this->id;
     } else {
         $this->id = $this->htmlOptions['id'];
     }
     if ($this->enableTranslate) {
         $this->initTranslate();
     }
 }
开发者ID:egorrishe,项目名称:yii-dropzone,代码行数:17,代码来源:EDropzone.php

示例12: resolveNameID

 /**
  * @return array the name and the ID of the input.
  * @throws \foundation\exception\InvalidConfigException
  */
 protected function resolveNameID()
 {
     if ($this->name !== null) {
         $name = $this->name;
     } elseif (isset($this->htmlOptions['name'])) {
         $name = $this->htmlOptions['name'];
     } elseif ($this->hasModel()) {
         $name = \CHtml::activeName($this->model, $this->attribute);
     } else {
         throw new InvalidConfigException(\Yii::t('yii', '{class} must specify "model" and "attribute" or "name" property values.', array('{class}' => get_class($this))));
     }
     if (($id = $this->getId(false)) === null) {
         if (isset($this->htmlOptions['id'])) {
             $id = $this->htmlOptions['id'];
         } else {
             $id = \CHtml::getIdByName($name);
         }
     }
     return array($name, $id);
 }
开发者ID:2amigos,项目名称:yiifoundation,代码行数:24,代码来源:Input.php

示例13: run

 /**
  * Runs the widget.
  */
 public function run()
 {
     $id = $this->id . '-file';
     $containerId = $this->id . '-container';
     $label = '选择文件';
     if ($this->hasModel()) {
         $name = CHtml::activeName($this->model, $this->attribute) . '[]';
         if ($this->form) {
             $label .= $this->form->fileField($this->model, $this->attribute, array('name' => $name, 'id' => $id, 'hideFocus' => true));
         } else {
             $label .= CHtml::activeFileField($this->model, $this->attribute, array('name' => $name, 'id' => $id, 'hideFocus' => true));
         }
     }
     $this->controller->widget('bootstrap.widgets.TbButton', array('label' => $label, 'size' => 'small', 'icon' => 'plus', 'encodeLabel' => false, 'htmlOptions' => $this->htmlOptions));
     echo CHtml::tag('div', array('id' => $containerId), '', true);
     Yii::app()->bootstrap->registerAssetCss('bootstrap-file-selector.css');
     $cs = Yii::app()->getClientScript();
     $cs->registerCoreScript('multifile');
     $cs->registerScript(__CLASS__ . '#' . $this->id, "\n\$('#{$id}').MultiFile(" . CJavaScript::encode($this->options) . ")");
 }
开发者ID:ruzuojun,项目名称:shiqu,代码行数:23,代码来源:TbFileSelector.php

示例14: resolveNameID

 /**
  * Resolves name and ID of the input. Source property of the name and/or source property of the attribute
  * could be customized by specifying first and/or second parameter accordingly.
  * @param string $nameProperty class property name which holds element name to be used. This parameter
  * is available since 1.1.14.
  * @param string $attributeProperty class property name which holds model attribute name to be used. This
  * parameter is available since 1.1.14.
  * @return array name and ID of the input: array('name','id').
  * @throws CException in case model and attribute property or name property cannot be resolved.
  */
 protected function resolveNameID($nameProperty = 'name', $attributeProperty = 'attribute')
 {
     if ($this->{$nameProperty} !== null) {
         $name = $this->{$nameProperty};
     } elseif (isset($this->htmlOptions[$nameProperty])) {
         $name = $this->htmlOptions[$nameProperty];
     } elseif ($this->hasModel()) {
         $name = CHtml::activeName($this->model, $this->{$attributeProperty});
     } else {
         throw new CException(Yii::t('zii', '{class} must specify "model" and "{attribute}" or "{name}" property values.', array('{class}' => get_class($this), '{attribute}' => $attributeProperty, '{name}' => $nameProperty)));
     }
     if (($id = $this->getId(false)) === null) {
         if (isset($this->htmlOptions['id'])) {
             $id = $this->htmlOptions['id'];
         } else {
             $id = CHtml::getIdByName($name);
         }
     }
     return array($name, $id);
 }
开发者ID:movoin,项目名称:yii-framework,代码行数:30,代码来源:CJuiInputWidget.php

示例15: run

 /**
  * Create a div and the appropriate Javascript to make the div into the file upload area
  */
 public function run()
 {
     if (!$this->url || $this->url == '') {
         $this->url = Yii::app()->createUrl('site/upload');
     }
     if (!$this->name && ($this->model && $this->attribute) && $this->model instanceof CModel) {
         $this->name = CHtml::activeName($this->model, $this->attribute);
     }
     echo CHtml::openTag('div', CMap::mergeArray(array('class' => 'dropzone', 'id' => $this->name), $this->htmlOptions));
     echo CHtml::closeTag('div');
     $this->mimeTypes = CJavaScript::encode($this->mimeTypes);
     $onEvents = '';
     foreach ($this->events as $event => $func) {
         $onEvents .= "this.on('{$event}', function(param, param2, param3){{$func}} );";
     }
     $options = CMap::mergeArray(array('url' => $this->url, 'parallelUploads' => 5, 'paramName' => $this->name, 'accept' => "js:function(file, done){if(jQuery.inArray(file.type,{$this->mimeTypes}) == -1 ){done('File type not allowed.');}else{done();}}", 'init' => "js:function(){{$onEvents}}"), $this->options);
     $options = CJavaScript::encode($options);
     $script = "Dropzone.options.{$this->name} = {$options}";
     $this->registerAssets();
     Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $this->getId(), $script, CClientScript::POS_LOAD);
 }
开发者ID:suckkay,项目名称:yii-dropzone,代码行数:24,代码来源:EDropzone.php


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