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


PHP CHtml::getIdByName方法代码示例

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


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

示例1: labelEx

 /**
  * @inheritDoc
  */
 public function labelEx($model, $attribute, $htmlOptions = array())
 {
     if (!$this->qualifyNames && !isset($htmlOptions['for'])) {
         $htmlOptions['for'] = \CHtml::getIdByName($attribute);
     }
     return parent::labelEx($model, $attribute, $htmlOptions);
 }
开发者ID:codemix,项目名称:restyii,代码行数:10,代码来源:ActiveForm.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: autoComplete

 function autoComplete($name, $complete_view, $id = '', $value = '')
 {
     $url = is_array($complete_view) ? $complete_view : array($complete_view);
     $dom_id = CHtml::getIdByName($name);
     echo CHtml::hiddenField($name, $id, array('id' => $dom_id));
     $this->widget('zii.widgets.jui.CJuiAutoComplete', array('name' => $dom_id . '_autocomplete', 'sourceUrl' => $url, 'options' => array('select' => "js:function(event, ui) {\n                                \$('#{$dom_id}').val(ui.item.id);\n                            }"), 'value' => $value));
 }
开发者ID:black2279,项目名称:Tracy-openshift,代码行数:7,代码来源:Controller.php

示例4: radioButtonList

 public static function radioButtonList($name, $select, $data, $htmlOptions = array())
 {
     $template = isset($htmlOptions['template']) ? $htmlOptions['template'] : '{input} {label}';
     $separator = isset($htmlOptions['separator']) ? $htmlOptions['separator'] : "<br/>\n";
     unset($htmlOptions['template'], $htmlOptions['separator']);
     $labelOptions = isset($htmlOptions['labelOptions']) ? $htmlOptions['labelOptions'] : array();
     unset($htmlOptions['labelOptions']);
     $items = array();
     $baseID = CHtml::getIdByName($name);
     $id = 0;
     foreach ($data as $value => $item) {
         $checked = !strcmp($value, $select);
         $htmlOptions['value'] = $value;
         $labelOptions['id'] = $baseID . '_label_' . $id;
         $htmlOptions['id'] = $baseID . '_' . $id++;
         $labelOptions['title'] = $item['title'];
         $htmlOptions['class'] = 'ui-icon ui-state-default ' . $item['class'];
         $option = CHtml::radioButton($name, $checked, $htmlOptions);
         if (!empty($item['icon'])) {
             $item['caption'] = '<span style="float:left;" class="ui-icon ' . $item['icon'] . '"> ' . $item['caption'] . '</span>' . $item['caption'];
         }
         $label = CHtml::label($item['caption'], $htmlOptions['id'], $labelOptions);
         $items[] = strtr($template, array('{input}' => $option, '{label}' => $label));
     }
     return CHtml::tag('span', array('id' => $baseID), implode($separator, $items));
 }
开发者ID:rosko,项目名称:Tempo-CMS,代码行数:26,代码来源:ButtonSet.php

示例5: run

 /**
  * Runs the widget.
  * This method registers all needed client scripts and renders
  * the multiple file uploader.
  */
 public function run()
 {
     if ($this->name !== null) {
         $name = $this->name;
     } else {
         if (isset($this->htmlOptions['name'])) {
             $name = $this->htmlOptions['name'];
         } else {
             throw new CException(Yii::t('yii', 'CMultiFileUpload.name is required.'));
         }
     }
     if (substr($name, -2) !== '[]') {
         $name .= '[]';
     }
     if (($id = $this->getId(false)) === null) {
         if (isset($this->htmlOptions['id'])) {
             $id = $this->htmlOptions['id'];
         } else {
             $id = CHtml::getIdByName($name);
         }
     }
     $this->htmlOptions['id'] = $id;
     $this->registerClientScript();
     echo CHtml::fileField($name, '', $this->htmlOptions);
 }
开发者ID:hansenmakangiras,项目名称:yiiframework-cms,代码行数:30,代码来源:CMultiFileUpload.php

示例6: labelEx

 /**
  * Renders an HTML label for a model attribute.
  * @param CModel $parentModel the parent data model
  * @param string $attributedPath the attribute or path to related model attribute
  * @param array $htmlOptions additional HTML attributes.
  * @return string the generated label tag
  */
 public function labelEx($parentModel, $attributedPath, $htmlOptions = array())
 {
     list($model, $attribute, $htmlOptions) = self::resolveArgs($parentModel, $attributedPath, $htmlOptions);
     $htmlOptions['for'] = CHtml::getIdByName($htmlOptions['name']);
     if (!isset($htmlOptions['label']) && ($label = self::resolveLabel($parentModel, $attributedPath)) !== null) {
         $htmlOptions['label'] = $label;
     }
     return parent::labelEx($model, $attribute, $htmlOptions);
 }
开发者ID:nov072008,项目名称:yiitesting,代码行数:16,代码来源:WForm.php

示例7: init

 public function init()
 {
     parent::init();
     $this->paramLink = array('id_field' => CHtml::getIdByName($this->fieldId), 'multileSelect' => $this->multiSelect ? 1 : 0);
     if (!$this->dialogZone) {
         $this->idZone = array('id' => 'showJobDialog', 'class' => 'ajaxlink');
         $this->updateZone = array('onclick' => '$("#jobDialog").dialog("open"); return false;', 'update' => '#jobDialog');
     } else {
         $this->paramLink['id_dialog'] = $this->dialogZone;
         $this->idZone = array('id' => $this->dialogZone . "-show", 'class' => 'ajaxlink');
         $this->updateZone = array('onclick' => '$("#jobDialog").dialog("open"); return false;', 'update' => '#dialog');
     }
     $this->link = $this->controller->createUrl('artist/popupList', $this->paramLink);
     $this->htmlOptions['readonly'] = 'readonly';
 }
开发者ID:giangnh264,项目名称:mobileplus,代码行数:15,代码来源:Feild.php

示例8: run

    public function run()
    {
        $cs = Yii::app()->getClientScript();
        $textAreaOptions = $this->gettextareaOptions();
        $textAreaOptions['name'] = CHtml::resolveName($this->model, $this->name);
        $this->id = $textAreaOptions['id'] = CHtml::getIdByName($textAreaOptions['name']);
        echo CHtml::activeTextArea($this->model, $this->name, $textAreaOptions);
        $properties_string = CJavaScript::encode($this->getKeProperties());
        $js = <<<EOF
KindEditor.ready(function(K) {
\tvar editor_{$this->id} = K.create('#{$this->id}', 
{$properties_string}
\t);
});
EOF;
        $cs->registerScript('KE' . $this->name, $js, CClientScript::POS_HEAD);
    }
开发者ID:diandianxiyu,项目名称:Yii1.x-admin,代码行数:17,代码来源:KEditor.php

示例9: init

 public function init()
 {
     parent::init();
     $this->paramLink = array('id_field' => CHtml::getIdByName($this->fieldId), 'name_field' => CHtml::getIdByName($this->fieldName));
     if (!$this->dialogZone) {
         $this->idZone = array('id' => 'showJobDialog', 'class' => 'ajaxlink');
         $this->updateZone = array('onclick' => '$("#jobDialog").dialog("open"); return false;', 'update' => '#jobDialog');
     } else {
         $this->paramLink['id_dialog'] = $this->dialogZone;
         $this->idZone = array('id' => $this->dialogZone . "-show", 'class' => 'ajaxlink');
         /*$this->updateZone = array(
               'onclick'=>'$("#'.$this->dialogZone.'").dialog("open"); return false;',
               'update'=>'#'.$this->dialogZone
           );*/
         $this->updateZone = array('onclick' => '$("#jobDialog").dialog("open"); return false;', 'update' => '#jobDialog');
         //echo "<div id='$this->dialogZone'></div>";
     }
     $this->link = $this->controller->createUrl('artist/popupList', $this->paramLink);
     $this->htmlOptions['readonly'] = 'readonly';
 }
开发者ID:giangnh264,项目名称:mobileplus,代码行数:20,代码来源:ArtistFeild.php

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

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

示例12: init

    public function init()
    {
        parent::init();
        $idTxt = CHtml::getIdByName($this->fieldName);
        $idById = CHtml::getIdByName($this->fieldId);
        Yii::app()->getClientScript()->registerCssFile(Yii::app()->theme->baseUrl . "/css/jquery.autocomplete.css");
        Yii::app()->clientScript->registerScriptFile(Yii::app()->theme->baseUrl . "/js/jquery.autocomplete.js");
        $link = Yii::app()->createUrl("artist/autoComplete");
        $script = <<<EOD
   \t    \$(document).ready(function() {
\t   \t    \$('#{$idTxt}').autocomplete('{$link}', {
\t\t\t\twidth: 260,
\t\t\t\tmatchContains: true,
\t\t\t\tmustMatch: true,
\t\t\t\tselectFirst: true
\t\t\t});
\t\t\t\$("#{$idTxt}").result(function(event, data, formatted) {
\t\t\t\t\$("#{$idTxt}").val(data[0]);
\t\t\t\t\$("#{$idById}").val(data[1]);
\t\t\t});
   \t    });
EOD;
        Yii::app()->clientScript->registerScript("artist-auto", $script, CClientScript::POS_HEAD);
    }
开发者ID:giangnh264,项目名称:mobileplus,代码行数:24,代码来源:ArtistAuto.php

示例13: init

 public function init()
 {
     $this->id = CHtml::getIdByName($this->name);
     parent::init();
     $this->publishAssets();
 }
开发者ID:giangnh264,项目名称:mobileplus,代码行数:6,代码来源:input.php

示例14: testGetIdByName

 /**
  * @dataProvider providerGetIdByName
  *
  * @param string $text
  * @param string $assertion
  */
 public function testGetIdByName($text, $assertion)
 {
     $this->assertEquals($assertion, CHtml::getIdByName($text));
 }
开发者ID:robregonm,项目名称:yii,代码行数:10,代码来源:CHtmlTest.php

示例15: resolveID

 protected function resolveID($attr)
 {
     $name = CHtml::activeName($this->model, $attr);
     $id = CHtml::getIdByName($name);
     return $id;
 }
开发者ID:CHILMEX,项目名称:amocasion,代码行数:6,代码来源:GMapInputWidget.php


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