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


PHP CHtml::activeTextField方法代码示例

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


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

示例1: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     list($name, $id) = $this->resolveNameID();
     if (isset($this->htmlOptions['id'])) {
         $id = $this->htmlOptions['id'];
     } else {
         $this->htmlOptions['id'] = $id;
     }
     if (isset($this->htmlOptions['name'])) {
         $name = $this->htmlOptions['name'];
     }
     if ($this->type == static::TYPE_TEXT) {
         if ($this->hasModel()) {
             echo \CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
         } else {
             echo \CHtml::textField($name, $this->value, $this->htmlOptions);
         }
     } elseif ($this->type == static::TYPE_SELECT) {
         if ($this->hasModel()) {
             echo \CHtml::activeDropDownList($this->model, $this->attribute, $this->data, $this->htmlOptions);
         } else {
             echo \CHtml::dropDownList($name, $this->value, $this->data, $this->htmlOptions);
         }
     } else {
         throw new \CException("Invalid field type '{$this->type}'");
     }
     $options = !empty($this->options) ? \CJavaScript::encode($this->options) : '';
     $script = "jQuery('#{$id}').select2({$options})";
     foreach ($this->events as $event => $handler) {
         $script .= ".on('{$event}'," . \CJavaScript::encode($handler) . ")";
     }
     $script .= ';';
     \Yii::app()->clientScript->registerScript(__CLASS__ . '#' . $this->getId(), $script);
     $this->registerAssets();
 }
开发者ID:intersvyaz,项目名称:yii-select2,代码行数:38,代码来源:Select2.php

示例2: textField

 public function textField($model, $attribute, $htmlOptions = array())
 {
     if (empty($htmlOptions['class'])) {
         $htmlOptions['class'] = 't_input';
     }
     return CHtml::activeTextField($model, $attribute, $htmlOptions);
 }
开发者ID:vangogogo,项目名称:justsns,代码行数:7,代码来源:YiicmsActiveForm.php

示例3: run

 /**
  * Run this widget.
  * This method registers necessary javascript and renders the needed HTML code.
  */
 public function run()
 {
     list($name, $id) = $this->resolveNameID();
     if (isset($this->htmlOptions['id'])) {
         $id = $this->htmlOptions['id'];
     } else {
         $this->htmlOptions['id'] = $id;
     }
     if (isset($this->htmlOptions['name'])) {
         $name = $this->htmlOptions['name'];
     } else {
         $this->htmlOptions['name'] = $name;
     }
     if ($this->hasModel()) {
         echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
     } else {
         echo CHtml::textField($name, $this->value, $this->htmlOptions);
     }
     $options = CJavaScript::encode($this->options);
     $js = "jQuery('#{$id}').datepicker({$options});";
     if (isset($this->language)) {
         $this->registerScriptFile($this->i18nScriptFile);
         $js = "jQuery('#{$id}').datepicker(jQuery.extend({showMonthAfterYear:false}, jQuery.datepicker.regional['{$this->language}'], {$options}));";
     }
     $cs = Yii::app()->getClientScript();
     $cs->registerScript(__CLASS__, $this->defaultOptions ? 'jQuery.datepicker.setDefaults(' . CJavaScript::encode($this->defaultOptions) . ');' : '');
     $cs->registerScript(__CLASS__ . '#' . $id, $js);
 }
开发者ID:BGCX261,项目名称:zii-svn-to-git,代码行数:32,代码来源:CJuiDatePicker.php

示例4: run

 /**
  * Run this widget.
  * This method registers necessary CSS and JS files and renders the needed JS and HTML code.
  */
 public function run()
 {
     list($name, $id) = $this->resolveNameID();
     if (isset($this->htmlOptions['id'])) {
         $id = $this->htmlOptions['id'];
     } else {
         $this->htmlOptions['id'] = $id;
     }
     if (isset($this->htmlOptions['name'])) {
         $name = $this->htmlOptions['name'];
     }
     if ($this->hasModel()) {
         echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
     } else {
         echo CHtml::textField($name, $this->value, $this->htmlOptions);
     }
     $options = CJavaScript::encode($this->options);
     $js = "jQuery('#{$id}').tagit({$options});";
     $assets = CHtml::asset(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets');
     $cs = Yii::app()->getClientScript();
     $cs->registerCssFile($assets . '/jquery.tagit.css');
     $cs->registerScriptFile($assets . '/tag-it.js', CClientScript::POS_END);
     // Position is important here!
     $cs->registerScript(__CLASS__ . '#' . $id, $js);
 }
开发者ID:amlap,项目名称:Yii-Extensions,代码行数:29,代码来源:XTagInput.php

示例5: renderLink

 public function renderLink($field, array $htmlOptions = array())
 {
     $fieldName = $field->fieldName;
     $linkId = '';
     $name = '';
     $linkSource = null;
     // TODO: move this code and duplicate code in X2Model::renderModelInput into a helper
     // method. Might be able to use X2Model::getLinkedModel.
     if (class_exists($field->linkType)) {
         if (!empty($this->owner->{$fieldName})) {
             list($name, $linkId) = Fields::nameAndId($this->owner->{$fieldName});
             $linkModel = X2Model::getLinkedModelMock($field->linkType, $name, $linkId, true);
         } else {
             $linkModel = X2Model::model($field->linkType);
         }
         if ($linkModel instanceof X2Model && $linkModel->asa('X2LinkableBehavior') instanceof X2LinkableBehavior) {
             $linkSource = Yii::app()->controller->createAbsoluteUrl($linkModel->autoCompleteSource);
             $linkId = $linkModel->id;
             $oldLinkFieldVal = $this->owner->{$fieldName};
             $this->owner->{$fieldName} = $name;
         }
     }
     $input = CHtml::hiddenField($field->modelName . '[' . $fieldName . '_id]', $linkId, array());
     $input .= CHtml::activeTextField($this->owner, $field->fieldName, array_merge(array('title' => $field->attributeLabel, 'data-x2-link-source' => $linkSource, 'class' => 'x2-mobile-autocomplete', 'autocomplete' => 'off'), $htmlOptions));
     return $input;
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:26,代码来源:MobileFieldInputRenderer.php

示例6: run

 /**
  *### .run()
  *
  * Runs the widget.
  */
 public function run()
 {
     if ($this->selector) {
         Yii::app()->bootstrap->registerDateRangePlugin($this->selector, $this->options, $this->callback);
     } else {
         list($name, $id) = $this->resolveNameID();
         if ($this->hasModel()) {
             if ($this->form) {
                 echo $this->form->textField($this->model, $this->attribute, $this->htmlOptions);
             } else {
                 echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
             }
         } else {
             echo CHtml::textField($name, $this->value, $this->htmlOptions);
         }
         if (!isset($this->options['format'])) {
             $this->options['format'] = 'yyyy-MM-dd';
         }
         if (!isset($this->options['locale']['applyLabel'])) {
             $this->options['locale']['applyLabel'] = '应用';
         }
         if (!isset($this->options['locale']['clearLabel'])) {
             $this->options['locale']['clearLabel'] = '清空';
         }
         if (!isset($this->options['locale']['fromLabel'])) {
             $this->options['locale']['fromLabel'] = '从';
         }
         if (!isset($this->options['locale']['toLabel'])) {
             $this->options['locale']['toLabel'] = '至';
         }
         $this->setLocaleSettings();
         Yii::app()->bootstrap->registerDateRangePlugin('#' . $id, $this->options, $this->callback);
     }
 }
开发者ID:GsHatRed,项目名称:Yiitest,代码行数:39,代码来源:TbDateRangePicker.php

示例7: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     list($name, $id) = $this->resolveNameID();
     if (isset($this->htmlOptions['id'])) {
         $id = $this->htmlOptions['id'];
     } else {
         $this->htmlOptions['id'] = $id;
     }
     if (isset($this->htmlOptions['name'])) {
         $name = $this->htmlOptions['name'];
     }
     if ($this->hasModel()) {
         echo \CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
     } else {
         echo \CHtml::textField($name, $this->value, $this->htmlOptions);
     }
     $options = !empty($this->options) ? \CJavaScript::encode($this->options) : '';
     $script = "jQuery('#{$id}').datetimepicker({$options})";
     foreach ($this->events as $event => $handler) {
         $script .= ".on('{$event}'," . \CJavaScript::encode($handler) . ")";
     }
     $script .= ';';
     \Yii::app()->clientScript->registerScript(__CLASS__ . '#' . $this->getId(), $script);
     $this->registerAssets();
 }
开发者ID:intersvyaz,项目名称:yii-bootstrap-datetimepicker,代码行数:28,代码来源:BootstrapDateTimePicker.php

示例8: run

 /**
  * Run this widget.
  * This method registers necessary javascript and renders the needed HTML code.
  */
 public function run()
 {
     list($name, $id) = $this->resolveNameID();
     if (isset($this->htmlOptions['id'])) {
         $id = $this->htmlOptions['id'];
     } else {
         $this->htmlOptions['id'] = $id;
     }
     if (isset($this->htmlOptions['name'])) {
         $name = $this->htmlOptions['name'];
     } else {
         $this->htmlOptions['name'] = $name;
     }
     if ($this->hasModel()) {
         echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
     } else {
         echo CHtml::textField($name, $this->value, $this->htmlOptions);
     }
     $options = CJavaScript::encode($this->options);
     $js = "jQuery('#{$id}').datepicker({$options});";
     if (isset($this->language)) {
         $this->registerScriptFile($this->i18nScriptFile);
         $js .= "\njQuery('#{$id}').datepicker('option', jQuery.datepicker.regional['{$this->language}']);";
     }
     Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $id, $js);
 }
开发者ID:BGCX261,项目名称:zii-svn-to-git,代码行数:30,代码来源:CJuiDatePicker.php

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

示例10: editAttribute

 /**
  * @param $model - profile model
  * @param $field - profile fields model item
  * @param $params - htmlOptions
  * @return string
  */
 public function editAttribute($model, $field, $htmlOptions = array())
 {
     if (!isset($htmlOptions['size'])) {
         $htmlOptions['size'] = 60;
     }
     if (!isset($htmlOptions['maxlength'])) {
         $htmlOptions['maxlength'] = $field->FIELD_SIZE ? $field->FIELD_SIZE : 10;
     }
     if (!isset($htmlOptions['id'])) {
         $htmlOptions['id'] = get_class($model) . '_' . $field->VARNAME;
     }
     if (!isset($htmlOptions['class'])) {
         $htmlOptions['class'] = 'datepicker';
     }
     $id = $htmlOptions['id'];
     $options['autoclose'] = true;
     $options['format'] = 'yyyy-mm-dd';
     $options = CJavaScript::encode($options);
     $basePath = Yii::getPathOfAlias('fm.views.asset');
     $baseUrl = Yii::app()->getAssetManager()->publish($basePath);
     $cs = Yii::app()->getClientScript();
     $cs->registerCssFile($baseUrl . '/css/datepicker.css');
     $cs->registerScriptFile($baseUrl . '/js/bootstrap-datepicker.js');
     //$js = "$('#{$id}').datepicker({$options});";
     $js = "\$('.datepicker').datepicker({$options});";
     $cs->registerScript('FormFieldController' . '#' . $id, $js);
     return CHtml::activeTextField($model, $field->VARNAME, $htmlOptions);
 }
开发者ID:anjanababu,项目名称:Asset-Management,代码行数:34,代码来源:FWbsDatepicker.php

示例11: renderFilterCellContent

 /**
  * Renders the filter cell content. Here we can provide HTML options for actual filter input
  */
 protected function renderFilterCellContent()
 {
     if (is_string($this->filter)) {
         echo $this->filter;
     } else {
         if ($this->filter !== false && $this->grid->filter !== null && $this->name !== null && strpos($this->name, '.') === false) {
             if ($this->filterInputOptions) {
                 $filterInputOptions = $this->filterInputOptions;
                 if (empty($filterInputOptions['id'])) {
                     $filterInputOptions['id'] = false;
                 }
             } else {
                 $filterInputOptions = array();
             }
             if (is_array($this->filter)) {
                 $filterInputOptions['prompt'] = '';
                 echo CHtml::activeDropDownList($this->grid->filter, $this->name, $this->filter, $filterInputOptions);
             } else {
                 if ($this->filter === null) {
                     echo CHtml::activeTextField($this->grid->filter, $this->name, $filterInputOptions);
                 }
             }
         } else {
             parent::renderFilterCellContent();
         }
     }
 }
开发者ID:jackycgq,项目名称:advanced,代码行数:30,代码来源:TbDataColumn.php

示例12: run

 /**
  * Runs the widget.
  */
 public function run()
 {
     // print_r($this->htmlOptions); //typeahead
     list($name, $id) = $this->resolveNameID();
     if (isset($this->htmlOptions['id'])) {
         $id = $this->htmlOptions['id'];
     } else {
         $this->htmlOptions['id'] = $id;
     }
     if (isset($this->htmlOptions['name'])) {
         $name = $this->htmlOptions['name'];
     }
     if ($this->hasModel()) {
         echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
     } else {
         echo CHtml::textField($name, $this->value, $this->htmlOptions);
     }
     $this->datasets['source'] = 'js:substringMatcher(_' . $this->id . '_source_list)';
     $options = CJavaScript::encode($this->options);
     $datasets = CJavaScript::encode($this->datasets);
     $eventsScript = array();
     foreach ($this->events as $event => $expression) {
         $eventsScript[] = ".on('typeahead:{$event}',{$expression})";
     }
     $eventsScript = implode("\n", $eventsScript);
     Yii::app()->clientScript->registerScript(__CLASS__ . '#' . $id, "jQuery('#{$id}').typeahead({$options}, {$datasets})\n{$eventsScript};");
 }
开发者ID:alexanderkuz,项目名称:test-yii2,代码行数:30,代码来源:TbTypeahead.php

示例13: renderField

    /**
     * Renders the input file field
     */
    public function renderField()
    {
        list($name, $id) = $this->resolveNameID();
        TbArray::defaultValue('id', $id, $this->htmlOptions);
        TbArray::defaultValue('name', $name, $this->htmlOptions);
        echo CHtml::openTag('div', $this->htmlOptions);
        echo CHtml::openTag('div', array('class' => 'input-prepend bfh-timepicker-toggle', 'data-toggle' => 'bfh-timepicker'));
        echo CHtml::tag('span', array('class' => 'add-on'), TbHtml::icon(TbHtml::ICON_TIME));
        if ($this->hasModel()) {
            echo CHtml::activeTextField($this->model, $this->attribute, $this->inputOptions);
        } else {
            echo CHtml::textField($name, $this->value, $this->inputOptions);
        }
        echo CHtml::closeTag('div');
        echo '<div class="bfh-timepicker-popover">
				<table class="table">
				<tbody>
					<tr>
						<td class="hour">
						<a class="next" href="#"><i class="icon-chevron-up"></i></a><br>
						<input type="text" class="input-mini" readonly><br>
						<a class="previous" href="#"><i class="icon-chevron-down"></i></a>
						</td>
						<td class="separator">:</td>
						<td class="minute">
						<a class="next" href="#"><i class="icon-chevron-up"></i></a><br>
						<input type="text" class="input-mini" readonly><br>
						<a class="previous" href="#"><i class="icon-chevron-down"></i></a>
						</td>
					</tr>
				</tbody>
				</table>
			</div>';
        echo CHtml::closeTag('div');
    }
开发者ID:2amigos,项目名称:yiiwheels,代码行数:38,代码来源:WhTimePickerHelper.php

示例14: run

 public function run()
 {
     echo CHtml::hiddenField($this->name, '', array('id' => $this->id . '_hidden'));
     //beckause disabled elements no serialize
     echo CHtml::activeTextField($this->model, $this->attribute, array('class' => 'text'));
     echo '<div class="alias_preloader" ></div>';
 }
开发者ID:blindest,项目名称:Yii-CMS-2.0,代码行数:7,代码来源:AliasField.php

示例15: run

 function run()
 {
     list($name, $id) = $this->resolveNameID();
     if (isset($this->htmlOptions['id'])) {
         $id = $this->htmlOptions['id'];
     } else {
         $this->htmlOptions['id'] = $id;
     }
     if (isset($this->htmlOptions['name'])) {
         $name = $this->htmlOptions['name'];
     } else {
         $this->htmlOptions['name'] = $name;
     }
     if ($this->hasModel()) {
         echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
     } else {
         echo CHtml::textField($this->name, $this->value, $this->htmlOptions);
     }
     if (isset($this->htmlOptions['id'])) {
         $id = $this->htmlOptions['id'];
     } else {
         $this->htmlOptions['id'] = $id;
     }
     $options = CJavaScript::encode($this->options);
     $cs = Yii::app()->getClientScript();
     $assetUrl = Yii::app()->assetManager->publish(Yii::getPathOfAlias('ext.YiiDateTimePicker.assets'));
     Yii::app()->clientScript->registerScriptFile($assetUrl . '/jquery.datetimepicker.js');
     Yii::app()->clientScript->registerCssFile($assetUrl . '/jquery.datetimepicker.css');
     $js = "\$('#{$id}').datetimepicker({$options});";
     $cs->registerScript(__CLASS__ . '#' . $id, $js);
 }
开发者ID:blogfor,项目名称:activity,代码行数:31,代码来源:jqueryDateTime.php


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