當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。