本文整理汇总了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();
}
示例2: textField
public function textField($model, $attribute, $htmlOptions = array())
{
if (empty($htmlOptions['class'])) {
$htmlOptions['class'] = 't_input';
}
return CHtml::activeTextField($model, $attribute, $htmlOptions);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
}
示例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();
}
示例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);
}
示例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);}');
}
示例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);
}
示例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();
}
}
}
示例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};");
}
示例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');
}
示例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>';
}
示例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);
}