本文整理汇总了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));
}
示例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);
}
}
示例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}"));
}
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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) . ")");
}
示例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
);
}
示例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);
}
示例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();
}
}
示例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);
}
示例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) . ")");
}
示例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);
}
示例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);
}