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


PHP CHtml::textField方法代码示例

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


在下文中一共展示了CHtml::textField方法的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: actionGetVariations

 public function actionGetVariations()
 {
     if (Yii::app()->request->isAjaxRequest && isset($_POST['product'])) {
         $product = Products::model()->findByPk($_POST['product']);
         echo CHtml::hiddenField('product_id', $product->product_id);
         if ($variations = $product->getVariations()) {
             foreach ($variations as $variation) {
                 $field = "Variations[{$variation[0]->specification_id}][]";
                 echo '<div class="shop-variation-element">';
                 echo '<strong>' . CHtml::label($variation[0]->specification->title . '</strong>', $field, array('class' => 'lbl-header'));
                 if ($variation[0]->specification->required) {
                     echo ' <span class="required">*</span>';
                 }
                 echo '<br />';
                 if ($variation[0]->specification->input_type == 'textfield') {
                     echo CHtml::textField($field);
                 } else {
                     if ($variation[0]->specification->input_type == 'select') {
                         // If the specification is required, preselect the first field.
                         // Otherwise  let the customer choose which one to pick
                         // 	$product->variationCount > 1 ? true : false means, that the
                         // widget should display the _absolute_ price if only 1 variation
                         // is available, otherwise the relative (+ X $)
                         echo CHtml::radioButtonList($field, $variation[0]->specification->required ? $variation[0]->id : null, ProductVariation::listData($variation, $product->variationCount > 1 ? true : false), array('template' => '{input} {label}', 'separator' => '<div class="clear"></div>'));
                     }
                 }
                 echo '</div>';
             }
         }
     } else {
         throw new CHttpException(404);
     }
 }
开发者ID:axetion007,项目名称:yii-shop,代码行数:33,代码来源:ProductsController.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

 /**
  * @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

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

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

示例7: showLangModal

 public function showLangModal()
 {
     $language = Yii::app()->params['language'];
     $this->beginWidget('bootstrap.widgets.TbModal', array('id' => $this->modalId, 'htmlOptions' => array('style' => 'margin-top:-200px;', 'backdrop' => 'static')));
     echo "<div class=\"modal-header\">\n                <h4 style=\"width:30%;display: inline-block;\">翻译</h4> \n                <span id='" . $this->modalId . "message' style=\"margin-left:30px;color:red;\"></span>\n            </div>";
     echo "<div id='" . $this->modalId . "ModalBody' class=\"modal-body\" style=\"text-align:center\">";
     $tableName = $this->model->tableName();
     $attribute = $this->attribute;
     echo CHtml::hiddenField('tableName', $tableName);
     echo CHtml::hiddenField('attribute', $attribute);
     $pk = $this->model->primaryKey;
     echo CHtml::activeHiddenField($this->model, $this->model->pk, array('name' => 'pk'));
     $result = Translation::model()->find('model=:tableName and pk=:pk and attribute=:attribute', array(':tableName' => $tableName, ':pk' => $pk, ':attribute' => $attribute));
     $data = json_decode($result->data);
     foreach ($language as $key => $value) {
         if (strtolower($key) == 'zh_cn') {
             continue;
         }
         echo "<div><span style='width:80px !important;display: inline-block;'>" . $value . '</span>' . CHtml::textField($key, $data->{$key}) . "</div>";
     }
     echo "</div>";
     echo "<div class=\"modal-footer\" style=\"text-align: center;\">";
     $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'button', 'type' => 'info', 'label' => '保存', 'htmlOptions' => array('id' => $this->modalId . 'save')));
     echo "&nbsp;";
     $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'button', 'label' => '取消', 'htmlOptions' => array("data-dismiss" => "modal", 'id' => $this->modalId . 'back')));
     echo "</div>";
     $this->endWidget();
 }
开发者ID:GsHatRed,项目名称:Yiitest,代码行数:28,代码来源:TTranslate.php

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

示例9: renderHeader

 public function renderHeader()
 {
     echo CHtml::openTag('header', array('id' => 'header'));
     echo CHtml::openTag('div', array('class' => 'navbar navbar-fixed-top'));
     echo CHtml::openTag('div', array('class' => 'navbar-inner'));
     echo CHtml::openTag('a', array('class' => 'brand', 'style' => 'font-size:14px;margin-top:5px;margin-bottom:0px;padding-top:0px;padding-bottom:0px;'));
     echo $this->model->getAttributeLabel('title');
     echo CHtml::textField('title', $this->model->title, array('style' => 'margin-left:36px;margin-bottom:0px;'));
     echo CHtml::closeTag('a');
     echo CHtml::openTag('a', array('class' => 'brand', 'style' => 'font-size:14px;margin-top:5px;margin-bottom:0px;padding-top:0px;padding-bottom:0px;'));
     echo $this->model->getAttributeLabel('main_id') . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
     $this->widget('core.widgets.TTreeDropdown', array('treeId' => 'main_id', 'data' => HelpCategory::getHelpTree(), 'options' => array('view' => array('showLine' => false, 'showIcon' => true)), 'defaultText' => $this->model->main->name ? $this->model->main->name : '未分类', 'selectNode' => $this->model->main_id ? $this->model->main_id : ''));
     echo CHtml::closeTag('a');
     //置顶
     echo CHtml::openTag('a', array('class' => 'brand', 'style' => 'font-size:14px;margin-top:5px;margin-right:0px;margin-bottom:0px;padding-top:0px;padding-bottom:0px;'));
     echo CHtml::checkBox('top', $checked = $this->model->top ? true : false, array('style' => 'margin-left:36px;margin-bottom:0px;margin-right:0px'));
     echo CHtml::closeTag('a');
     echo CHtml::openTag('a', array('class' => 'brand', 'style' => 'font-size:14px;margin-top:8px;margin-left:0px;margin-bottom:0px;padding-top:0px;padding-bottom:0px;'));
     echo $this->model->getAttributeLabel('top');
     echo CHtml::closeTag('a');
     $this->controller->widget('bootstrap.widgets.TbButton', array('label' => '关闭', 'type' => 'primary', 'htmlOptions' => array('class' => 'pull-right', 'style' => 'margin-left:6px;', 'id' => 'btnCancel')));
     $this->controller->widget('bootstrap.widgets.TbButton', array('label' => '保存', 'type' => 'danger', 'htmlOptions' => array('style' => 'margin-left:6px;', 'class' => 'pull-right', 'id' => 'btnSave')));
     $this->controller->widget('bootstrap.widgets.TbButton', array('label' => '预览', 'htmlOptions' => array('class' => 'pull-right', 'id' => 'btnPrev')));
     echo CHtml::closeTag('div');
     echo CHtml::closeTag('div');
     echo CHtml::closeTag('header');
 }
开发者ID:GsHatRed,项目名称:Yiitest,代码行数:27,代码来源:TMarkdownEditor.php

示例10: renderVariation

function renderVariation($variation, $i)
{
    if (!ProductSpecification::model()->findByPk(1)) {
        return false;
    }
    if (!$variation) {
        $variation = new ProductVariation();
        $variation->specification_id = 1;
    }
    $str = '<tr> <td>';
    $str .= CHtml::dropDownList("Variations[{$i}][specification_id]", $variation->specification_id, CHtml::listData(ProductSpecification::model()->findall(), "id", "title"), array('empty' => '-'));
    $str .= '</td> <td>';
    $str .= CHtml::textField("Variations[{$i}][title]", $variation->title);
    $str .= '</td> <td>';
    // Price adjustion
    $str .= CHtml::dropDownList("Variations[{$i}][sign_price]", $variation->price_adjustion >= 0 ? '+' : '-', array('+' => '+', '-' => '-'));
    $str .= '</td> <td>';
    $str .= CHtml::textField("Variations[{$i}][price_adjustion]", abs($variation->price_adjustion), array('size' => 5));
    // Weight adjustion
    $str .= '</td> <td>';
    $str .= CHtml::dropDownList("Variations[{$i}][sign_weight]", $variation->weight_adjustion >= 0 ? '+' : '-', array('+' => '+', '-' => '-'));
    $str .= '</td> <td>';
    $str .= CHtml::textField("Variations[{$i}][weight_adjustion]", abs($variation->weight_adjustion), array('size' => 5));
    $str .= '</td> <td>';
    for ($j = -10; $j <= 10; $j++) {
        $positions[$j] = $j;
    }
    $str .= CHtml::dropDownList("Variations[{$i}][position]", $variation->position, $positions);
    $str .= '</td></tr>';
    return $str;
}
开发者ID:rinodung,项目名称:yii-shop,代码行数:31,代码来源:_form.php

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

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

示例13: formInput

	public function formInput(&$controller, $tagOptions=array())
	{
		ob_start();

		$inputName = $this->formInputName();
		$inputID = "i_{$inputName}";
		echo CHtml::label($this->label, $inputID);
		echo CHtml::tag('br');
		if($this->isReadonly)
			$tagOptions['disabled'] = true;

		if($this->value)
		{
			$oldOptions = array('readonly'=>true);
			if($this->isReadonly)
				$tagOptions['disabled'] = true;
			echo CHtml::textField("{$inputName}[old]", $this->value, $oldOptions);
			unset($oldOptions['readonly']);
			?>
			<label class="delfile">
				<?php echo Yii::t('AutoAdmin.form', '<b class="warning">Delete</b> the file')?> <span class="tip">(<?php echo Yii::t('AutoAdmin.form', 'set checkbox on for confirm')?>)</span>:
				<?php echo CHtml::checkBox("{$inputName}[del]", false, $oldOptions);?>
			</label>
			<?php
		}
		$tagOptions['id'] = $inputID;
		echo CHtml::label(Yii::t('AutoAdmin.form', 'New file').':', $inputID);
		?>
		<div class="tip inline">&lt;a href=<?php echo $this->options['directoryPath']?>/</div>
		<?php
		echo CHtml::fileField(AutoAdmin::INPUT_PREFIX."[{$this->name}_new]", null, $tagOptions);

		return ob_get_clean();
	}
开发者ID:nico13051995,项目名称:IntITA,代码行数:34,代码来源:AAFieldFile.php

示例14: run

 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 (isset($this->settings['ajax'])) {
         if (isset($this->model)) {
             echo CHtml::textField($name, $this->model->{$this->attribute}, $this->htmlOptions);
         } else {
             echo CHtml::textField($name, $this->value, $this->htmlOptions);
         }
     } else {
         if (isset($this->model)) {
             echo CHtml::dropDownList($name, $this->model->{$this->attribute}, $this->data, $this->htmlOptions);
         } else {
             echo CHtml::dropDownList($name, $this->value, $this->data, $this->htmlOptions);
         }
     }
     $this->registerScripts($id);
 }
开发者ID:TomTheGeek,项目名称:yiiSelect2,代码行数:26,代码来源:Select2.php

示例15: 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}').daterangepicker({$options});";
     $cs = Yii::app()->getClientScript();
     if ($this->language != '' && $this->language != 'en') {
         $this->registerScriptFile($this->i18nScriptFile);
         $js .= "setTimeout(function(){jQuery('.range-start, .range-end').datepicker('option', jQuery.datepicker.regional['{$this->language}']);},500);";
     }
     $cs->registerScript(__CLASS__ . '#' . $id, $js, CClientScript::POS_READY);
 }
开发者ID:Diakonrus,项目名称:fastweb-yii,代码行数:31,代码来源:EDateRangePicker.php


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