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


PHP CHtml::activeId方法代码示例

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


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

示例1: validateMultiple

 public static function validateMultiple($models, $attributes = null, $loadInput = true)
 {
     $result = array();
     if (!is_array($models)) {
         $models = array($models);
     }
     foreach ($models as $i => $model) {
         if (is_array($_POST[get_class($model)])) {
             foreach ($_POST[get_class($model)] as $j => $m) {
                 if ($loadInput && isset($_POST[get_class($model)][$j])) {
                     $model->attributes = $_POST[get_class($model)][$j];
                 }
                 $model->validate($attributes);
                 foreach ($model->getErrors() as $attribute => $errors) {
                     $result[CHtml::activeId($model, '[' . $j . ']' . $attribute)] = $errors;
                 }
             }
         } else {
             if ($loadInput && isset($_POST[get_class($model)])) {
                 $model->attributes = $_POST[get_class($model)];
             }
             $model->validate($attributes);
             foreach ($model->getErrors() as $attribute => $errors) {
                 $result[CHtml::activeId($model, $attribute)] = $errors;
             }
         }
     }
     return function_exists('json_encode') ? json_encode($result) : CJSON::encode($result);
 }
开发者ID:Rudianasaja,项目名称:cycommerce,代码行数:29,代码来源:GxActiveForm.php

示例2: getAdminForm

 public function getAdminForm()
 {
     if (empty($this->origincountry)) {
         $this->origincountry = (int) _xls_get_conf('DEFAULT_COUNTRY', 224);
     }
     return array('title' => 'Note: You can ' . CHtml::link('Set Product Restrictions', '#', array('class' => 'basic', 'id' => get_class($this))) . ' for this module.', 'elements' => array('label' => array('type' => 'text', 'maxlength' => 64), 'mode' => array('type' => 'dropdownlist', 'items' => array('UPS' => 'Domestic US UPS Mode', 'IUPS' => 'IUPS International UPS Mode')), 'username' => array('type' => 'text', 'maxlength' => 64), 'password' => array('type' => 'text', 'maxlength' => 64), 'accesskey' => array('type' => 'text', 'maxlength' => 64), 'originpostcode' => array('type' => 'text', 'maxlength' => 64), 'origincountry' => array('type' => 'dropdownlist', 'items' => CHtml::listData(Country::model()->findAllByAttributes(array('active' => 1), array('order' => 'sort_order,country')), 'id', 'country'), 'ajax' => array('type' => 'POST', 'url' => Yii::app()->controller->createUrl('ajax/getstates'), 'data' => 'js:{"' . 'country_id' . '": $("#' . CHtml::activeId($this, 'origincountry') . ' option:selected").val()}', 'update' => '#' . CHtml::activeId($this, 'originstate'))), 'originstate' => array('type' => 'dropdownlist', 'items' => CHtml::listData(State::model()->findAllByAttributes(array('country_id' => $this->origincountry, 'active' => 1), array('order' => 'sort_order,state')), 'id', 'code')), 'offerservices' => array('type' => 'checkboxlist', 'items' => ups::$service_types, 'separator' => '', 'template' => '<div class="offerservices">{input} {label}</div>', 'label' => 'Offer these services<br><a onclick="selectall()">Select All</a><br><a onclick="selectnone()">Select None</a><br>'), 'package' => array('type' => 'dropdownlist', 'items' => ups::$package_types), 'ratecode' => array('type' => 'dropdownlist', 'items' => ups::$rate_types), 'customerclassification' => array('type' => 'dropdownlist', 'items' => array('04' => 'Retail', '03' => 'Occasional', '01' => 'Wholesale')), 'restrictcountry' => array('type' => 'dropdownlist', 'items' => Country::getAdminRestrictionList(true)), 'markup' => array('type' => 'text', 'maxlength' => 4), 'product' => array('type' => 'text', 'maxlength' => 64)));
 }
开发者ID:uiDeveloper116,项目名称:webstore,代码行数:7,代码来源:upsAdminForm.php

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

示例4: capturePosition

 /**
  * Capture the latitude and longitude of the marker to a model.
  * 
  * @param CModel $model Model object
  * @param string $lat Attribute name for latitude
  * @param string $lng Attribute name for longitude
  * @param array $options Options to set :<ul>
  * <li>'visible' - show the input fields
  * <li>'nocallback' - do not update on callback
  * <li>'nodragend' - do not update on dragend
  * <li>'drag' - update on drag
  * </ul>
  */
 public function capturePosition(CModel $model, $lat, $lng, array $options = array())
 {
     // field options
     if (in_array('visible', $options)) {
         echo CHtml::activeLabelEx($model, $lat), CHtml::activeTextField($model, $lat);
         echo '<br>';
         echo CHtml::activeLabelEx($model, $lng), CHtml::activeTextField($model, $lng);
     } else {
         echo CHtml::activeHiddenField($model, $lat), CHtml::activeHiddenField($model, $lng);
     }
     $latId = CHtml::activeId($model, $lat);
     $lngId = CHtml::activeId($model, $lng);
     // update function
     $jsFunction = "function captureMarkerPosition(marker){\$('#{$latId}').val(marker.getPosition().lat());\$('#{$lngId}').val(marker.getPosition().lng());}";
     Yii::app()->getClientScript()->registerScript(__CLASS__ . '#capturePosition', $jsFunction, CClientScript::POS_END);
     // event options
     if (!in_array('nocallback', $options)) {
         $this->addCallback('function(result){captureMarkerPosition(result);}');
     }
     if (!in_array('nodragend', $options)) {
         $this->addEvent('dragend', 'function(result){captureMarkerPosition(result);}');
     }
     if (in_array('drag', $options)) {
         $this->addEvent('drag', 'function(result){captureMarkerPosition(result);}');
     }
     $this->addEvent('position_changed', 'function(result){captureMarkerPosition(result);}');
 }
开发者ID:schyzoo,项目名称:YiiBoilerplate,代码行数:40,代码来源:EGmap3Marker.php

示例5: getAdminForm

 public function getAdminForm()
 {
     if (empty($this->origincountry)) {
         $this->origincountry = (int) _xls_get_conf('DEFAULT_COUNTRY', 224);
     }
     return array('title' => 'Note: You can ' . CHtml::link('Set Product Restrictions', '#', array('class' => 'basic', 'id' => get_class($this))) . ' for this module.', 'elements' => array('label' => array('type' => 'text', 'maxlength' => 64), 'accnumber' => array('type' => 'text', 'maxlength' => 64), 'meternumber' => array('type' => 'text', 'maxlength' => 64), 'securitycode' => array('type' => 'text', 'maxlength' => 64), 'authkey' => array('type' => 'text', 'maxlength' => 64), 'originadde' => array('type' => 'text', 'maxlength' => 64), 'origincity' => array('type' => 'text', 'maxlength' => 64), 'originpostcode' => array('type' => 'text', 'maxlength' => 64), 'origincountry' => array('type' => 'dropdownlist', 'items' => CHtml::listData(Country::model()->findAllByAttributes(array('active' => 1), array('order' => 'sort_order,country')), 'id', 'country'), 'ajax' => array('type' => 'POST', 'url' => Yii::app()->controller->createUrl('ajax/getstates'), 'data' => 'js:{"' . 'country_id' . '": $("#' . CHtml::activeId($this, 'origincountry') . ' option:selected").val()}', 'update' => '#' . CHtml::activeId($this, 'originstate'))), 'originstate' => array('type' => 'dropdownlist', 'items' => CHtml::listData(State::model()->findAllByAttributes(array('country_id' => $this->origincountry, 'active' => 1), array('order' => 'sort_order,state')), 'id', 'code')), 'offerservices' => array('type' => 'checkboxlist', 'items' => fedex::$service_types, 'separator' => '', 'template' => '<div class="offerservices">{input} {label}</div>', 'label' => 'Offer these services<br><a onclick="selectall()">Select All</a><br><a onclick="selectnone()">Select None</a><br>'), 'packaging' => array('type' => 'dropdownlist', 'items' => array('YOUR_PACKAGING' => 'Your packaging', 'FEDEX_BOX' => 'FedEx Box', 'FEDEX_PAK' => 'FedEx Pak', 'FEDEX_TUBE' => 'FedEx Tube')), 'ratetype' => array('type' => 'dropdownlist', 'items' => array('RATED_LIST' => 'List Rates', 'RATED_ACCOUNT' => 'Negotiated rates')), 'customs' => array('type' => 'dropdownlist', 'items' => array('CLEARANCEFEE' => 'FedEx Handles Customs Clearance', 'NOCHARGE' => 'My store handles Customs Clearance')), 'restrictcountry' => array('type' => 'dropdownlist', 'items' => Country::getAdminRestrictionList(true)), 'markup' => array('type' => 'text', 'maxlength' => 4), 'product' => array('type' => 'text', 'maxlength' => 64)));
 }
开发者ID:uiDeveloper116,项目名称:webstore,代码行数:7,代码来源:fedexAdminForm.php

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

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

示例8: getJsonErrors

/**
 * Format errors of model's attributes in JSON
 * to use for CActiveForm with validateOnSubmit
 *
 * @param mixed $model
 */
function getJsonErrors($model)
{
    $errors = array();
    foreach ($model->getErrors() as $attribute => $errs) {
        $errors[CHtml::activeId($model, $attribute)] = $errs;
    }
    return CJSON::encode($errors);
}
开发者ID:hung5s,项目名称:yap,代码行数:14,代码来源:mics.php

示例9: init

 /**
  * Initializes the widget.
  * This method will publish jQuery and miniColors plugin assets if necessary.
  * @return void
  */
 public function init()
 {
     $activeId = CHtml::activeId($this->model, $this->attribute);
     self::registerScriptFiles();
     $options = CJavaScript::encode($this->options);
     $cs = Yii::app()->getClientScript();
     $cs->registerScript('miniColors-' . $activeId, '$("#' . $activeId . '").miniColors(' . $options . ');');
 }
开发者ID:uiDeveloper116,项目名称:webstore,代码行数:13,代码来源:SActiveColorPicker.php

示例10: captureZoom

 /**
  * Capture the map's zoom level to a field
  * 
  * @param CModel $model Model containing the attribute
  * @param string $attribute Name of the model's attribute
  * @param boolean $generate Whether to generate the field
  * @param array $htmlOptions HTML options for the field
  */
 public function captureZoom(CModel $model, $attribute, $generate = true, array $htmlOptions = array())
 {
     if ($generate) {
         echo CHtml::activeHiddenField($model, $attribute, $htmlOptions);
     }
     $attId = CHtml::activeId($model, $attribute);
     $this->addEvent('zoom_changed', "function(map){\$('#{$attId}').val(map.getZoom());}");
 }
开发者ID:romeo14,项目名称:pow,代码行数:16,代码来源:EGmap3Map.php

示例11: resolveId

 protected function resolveId($model, $attribute)
 {
     $id = CHtml::activeId($model, $attribute);
     if ($this->inputPrefixData == null) {
         return $id;
     }
     $inputIdPrefix = Element::resolveInputIdPrefixIntoString($this->inputPrefixData);
     return str_replace(get_class($model), $inputIdPrefix, $id);
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:9,代码来源:WizardActiveForm.php

示例12: init

 public function init()
 {
     $this->options['onSubmit'] = 'js:function(hsb,hex,rgb,el) { $(el).val(hex); $(el).ColorPickerHide(); }';
     $options = CJavaScript::encode($this->options);
     $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'source';
     $this->baseUrl = Yii::app()->getAssetManager()->publish($dir);
     $cs = Yii::app()->getClientScript();
     $cs->registerScriptFile($this->baseUrl . '/js/colorpicker.js');
     $cs->registerCssFile($this->baseUrl . '/css/colorpicker.css');
     $activeId = CHtml::activeId($this->model, $this->attribute);
     $cs->registerScript($activeId . '-Script', '$("#' . $activeId . '").ColorPicker(' . $options . ');');
 }
开发者ID:kostya1017,项目名称:our,代码行数:12,代码来源:JColorPicker.php

示例13: init

 /**
  * Initializes the widget.
  * This method will publish jQuery and miniColors plugin assets if necessary.
  * @return void
  */
 public function init()
 {
     $activeId = CHtml::activeId($this->model, $this->attribute);
     $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'source';
     $baseUrl = Yii::app()->getAssetManager()->publish($dir);
     $cs = Yii::app()->getClientScript();
     $cs->registerCoreScript('jquery');
     $cs->registerScriptFile($baseUrl . '/jquery.miniColors.min.js');
     $cs->registerCssFile($baseUrl . '/jquery.miniColors.css');
     $options = CJavaScript::encode($this->options);
     $cs->registerScript('miniColors-' . $activeId, '$("#' . $activeId . '").miniColors(' . $options . ');');
 }
开发者ID:sharmarakesh,项目名称:edusec-college-management-system,代码行数:17,代码来源:SActiveColorPicker.php

示例14: error

 /**
  * Displays the first validation error for a model attribute.
  * @param CModel $model the data model
  * @param string $attribute the attribute name
  * @param array $htmlOptions additional HTML attributes to be rendered in the container div tag.
  * @param boolean $enableAjaxValidation whether to enable AJAX validation for the specified attribute.
  * @param boolean $enableClientValidation whether to enable client-side validation for the specified attribute.
  * @return string the validation result (error display or success message).
  */
 public function error($model, $attribute, $htmlOptions = array(), $enableAjaxValidation = true, $enableClientValidation = true)
 {
     if (!$this->enableAjaxValidation) {
         $enableAjaxValidation = false;
     }
     if (!$this->enableClientValidation) {
         $enableClientValidation = false;
     }
     if (!$enableAjaxValidation && !$enableClientValidation) {
         return TbHtml::error($model, $attribute, $htmlOptions);
     }
     $id = CHtml::activeId($model, $attribute);
     $inputID = TbArray::getValue('inputID', $htmlOptions, $id);
     unset($htmlOptions['inputID']);
     TbArray::defaultValue('id', $inputID . '_em_', $htmlOptions);
     $option = array('id' => $id, 'inputID' => $inputID, 'errorID' => $htmlOptions['id'], 'model' => get_class($model), 'name' => $attribute, 'enableAjaxValidation' => $enableAjaxValidation, 'inputContainer' => 'div.form-group', 'errorCssClass' => 'has-error', 'successCssClass' => 'has-success');
     $optionNames = array('validationDelay', 'validateOnChange', 'validateOnType', 'hideErrorMessage', 'inputContainer', 'errorCssClass', 'successCssClass', 'validatingCssClass', 'beforeValidateAttribute', 'afterValidateAttribute');
     foreach ($optionNames as $name) {
         if (isset($htmlOptions[$name])) {
             $option[$name] = TbArray::popValue($name, $htmlOptions);
         }
     }
     if ($model instanceof CActiveRecord && !$model->isNewRecord) {
         $option['status'] = 1;
     }
     if ($enableClientValidation) {
         $validators = TbArray::getValue('clientValidation', $htmlOptions, array());
         $attributeName = $attribute;
         if (($pos = strrpos($attribute, ']')) !== false && $pos !== strlen($attribute) - 1) {
             $attributeName = substr($attribute, $pos + 1);
         }
         /** @var CValidator $validator */
         foreach ($model->getValidators($attributeName) as $validator) {
             if ($validator->enableClientValidation) {
                 if (($js = $validator->clientValidateAttribute($model, $attributeName)) != '') {
                     $validators[] = $js;
                 }
             }
         }
         if ($validators !== array()) {
             $validators = implode("\n", $validators);
             $option['clientValidation'] = "js:function(value, messages, attribute) {\n{$validators}\n}";
         }
     }
     $html = TbHtml::error($model, $attribute, $htmlOptions);
     if ($html === '') {
         $htmlOptions['type'] = $this->helpType;
         TbHtml::addCssStyle('display:none', $htmlOptions);
         $html = TbHtml::help('', $htmlOptions);
     }
     $this->attributes[$inputID] = $option;
     return $html;
 }
开发者ID:itzen,项目名称:yiistrap,代码行数:62,代码来源:TbActiveForm.php

示例15: getErrorsForForm

 /** Retrieves encoded array with errors for ajax form validation
  * @param bool $encodeForAjax
  * @return array|string
  */
 public function getErrorsForForm($encodeForAjax = TRUE)
 {
     $result = array();
     foreach ($this->getErrors() as $attribute => $errors) {
         $result[CHtml::activeId($this, $attribute)] = $errors;
     }
     if ($encodeForAjax) {
         return function_exists('json_encode') ? json_encode($result) : CJSON::encode($result);
     } else {
         return $result;
     }
 }
开发者ID:andrelinoge,项目名称:rezydent,代码行数:16,代码来源:BaseTable.php


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