本文整理汇总了PHP中CHtml::resolveValue方法的典型用法代码示例。如果您正苦于以下问题:PHP CHtml::resolveValue方法的具体用法?PHP CHtml::resolveValue怎么用?PHP CHtml::resolveValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CHtml
的用法示例。
在下文中一共展示了CHtml::resolveValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
if (!$this->hasModel() && !isset($this->name)) {
throw new CHttpException(500, 'Parameters "model" and "attribute" or "name" have to be set!');
}
$ok = $this->attribute;
if (!empty($this->model) && $ok) {
$oCKeditor = new CKeditor();
$this->value = CHtml::resolveValue($this->model, $this->attribute);
list($this->name, $id) = $this->resolveNameID();
} elseif (!empty($this->name)) {
$oCKeditor = new CKeditor();
$this->value = isset($this->value) ? $this->value : null;
}
$oCKeditor->basePath = $this->baseurl . "/ckeditor/";
$oCKeditor->config['height'] = $this->height;
$oCKeditor->config['width'] = $this->width;
if (isset($this->config) && is_array($this->config)) {
foreach ($this->config as $key => $value) {
$oCKeditor->config[$key] = $value;
}
}
if ($this->filespath && $this->filesurl) {
$oCKeditor->config['filebrowserBrowseUrl'] = $this->kcFinderPath . 'browse.php?type=files';
$oCKeditor->config['filebrowserImageBrowseUrl'] = $this->kcFinderPath . 'browse.php?type=images';
$oCKeditor->config['filebrowserFlashBrowseUrl'] = $this->kcFinderPath . 'browse.php?type=flash';
$oCKeditor->config['filebrowserUploadUrl'] = $this->kcFinderPath . 'upload.php?type=files';
$oCKeditor->config['filebrowserImageUploadUrl'] = $this->kcFinderPath . 'upload.php?type=images';
$oCKeditor->config['filebrowserFlashUploadUrl'] = $this->kcFinderPath . 'upload.php?type=flash';
$session = new CHttpSession();
$session->open();
$session['KCFINDER'] = array('disabled' => false, 'uploadURL' => $this->filesurl, 'uploadDir' => realpath($this->filespath) . '/');
}
$oCKeditor->editor($this->name, isset($this->value) ? $this->value : null);
}
示例2: init
/**
* Initializes the widget.
*/
public function init()
{
if (is_null($this->theme)) {
$this->theme = 'default';
}
// check if options parameter is a json string
if (is_string($this->options)) {
if (!($this->options = CJSON::decode($this->options))) {
throw new CException('The options parameter is not valid JSON.');
}
}
// merge options with default values
$defaultOptions = array();
$this->options = CMap::mergeArray($defaultOptions, $this->options);
// merge options with Javascript events
$normalizedEvents = array();
foreach ($this->events as $name => $handler) {
$normalizedEvents[$name] = new CJavaScriptExpression($handler);
}
$this->options = CMap::mergeArray($normalizedEvents, $this->options);
// set field initial value
if (isset($this->options['formatSubmit'])) {
if (!isset($this->htmlOptions['data-value']) && $this->hasModel()) {
$this->htmlOptions['data-value'] = CHtml::resolveValue($this->model, $this->attribute);
}
}
// prepend pickadate scripts to the begining of the additional js files array
if (!empty($this->language)) {
array_unshift($this->scripts, "translations/{$this->language}");
}
array_unshift($this->scripts, 'picker.date');
array_unshift($this->scripts, $this->baseScript);
}
示例3: 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->model)) {
echo CHtml::textArea($name, CHtml::resolveValue($this->model, $this->attribute), $this->htmlOptions);
} else {
echo CHtml::textArea($name, $this->value, $this->htmlOptions);
}
$this->registerScripts($id);
}
示例4: activeRadioButtonList
public static function activeRadioButtonList($model, $attribute, $data, $htmlOptions = array())
{
CHtml::resolveNameID($model, $attribute, $htmlOptions);
$selection = CHtml::resolveValue($model, $attribute);
if ($model->hasErrors($attribute)) {
CHtml::addErrorCss($htmlOptions);
}
$name = $htmlOptions['name'];
unset($htmlOptions['name']);
if (array_key_exists('uncheckValue', $htmlOptions)) {
$uncheck = $htmlOptions['uncheckValue'];
unset($htmlOptions['uncheckValue']);
} else {
$uncheck = '';
}
$hiddenOptions = isset($htmlOptions['id']) ? array('id' => CHtml::ID_PREFIX . $htmlOptions['id']) : array('id' => false);
$hidden = $uncheck !== null ? CHtml::hiddenField($name, $uncheck, $hiddenOptions) : '';
return $hidden . self::radioButtonList($name, $selection, $data, $htmlOptions);
}
示例5: run
public function run()
{
if ($this->selector == null) {
list($this->name, $this->id) = $this->resolveNameId();
$this->selector = '#' . $this->id;
}
if (!isset($this->htmlOptions['value'])) {
if ($this->hasModel()) {
$this->value = CHtml::resolveValue($this->model, $this->attribute);
}
} else {
$this->value = $this->htmlOptions['value'];
unset($this->htmlOptions['value']);
}
$this->htmlOptions['autocomplete'] = 'off';
self::initClientScript($this->scriptPosition, $this->bootstrapVersion);
$options = $this->options ? CJavaScript::encode($this->options) : '';
Yii::app()->clientScript->registerScript(__CLASS__ . '#' . $this->id, "jQuery('{$this->selector}').datepicker({$options})");
echo CHtml::textField($this->name, $this->value, $this->htmlOptions);
}
示例6: run
/**
* Runs the widget.
*/
public function run()
{
if (!isset($this->uploadFolder) || !isset($this->uploadActionUrl) || !isset($this->cropActionUrl)) {
throw new CException("uploadFolder, uploadActionUrl, and cropActionUrl are required.");
}
list($name, $id) = $this->resolveNameID();
$imagePath = $this->value;
$imageTag = '';
if ($this->hasModel()) {
if ($this->form) {
$content = $this->form->hiddenField($this->model, $this->attribute, $this->htmlOptions);
} else {
$content = CHtml::activeHiddenField($this->model, $this->attribute, $this->htmlOptions);
}
$imagePath = CHtml::resolveValue($this->model, $this->attribute);
if (isset($this->model->attributes[$this->existingFileAttribute])) {
if ($this->model->attributes[$this->existingFileAttribute] != '') {
if (isset($this->existingFileAttribute)) {
$imagePath = CHtml::resolveValue($this->model, $this->existingFileAttribute);
}
if (isset($this->existingFileFolder) && ($imagePath != null && $imagePath != '')) {
$imagePath = $this->existingFileFolder . '/' . $imagePath;
}
}
}
} else {
$content = CHtml::hiddenField($name, $this->value, $this->htmlOptions);
}
if ($imagePath != null && $imagePath != '') {
$imageTag = CHtml::image($imagePath . '?_=' . time());
}
$content .= CHtml::tag('div', array('id' => $id . $this->uploadIdPostFix), '', true);
$content .= CHtml::tag('div', array('id' => $id . $this->imageIdPostFix), $imageTag, true);
echo CHtml::tag($this->tag, $this->tagHtmlOptions, $content, true);
$this->registerClientScript($id);
}
示例7: inputsList
/**
* Renders an input list.
* @param boolean $checkbox flag that indicates if the list is a checkbox-list.
* @param CModel $model the data model
* @param string $attribute the attribute
* @param array $data value-label pairs used to generate the input list.
* @param array $htmlOptions additional HTML options.
* @return string the generated input list.
* @since 0.9.5
*/
protected function inputsList($checkbox, $model, $attribute, $data, $htmlOptions = array())
{
CHtml::resolveNameID($model, $attribute, $htmlOptions);
$select = CHtml::resolveValue($model, $attribute);
if ($model->hasErrors($attribute)) {
if (isset($htmlOptions['class'])) {
$htmlOptions['class'] .= ' ' . CHtml::$errorCss;
} else {
$htmlOptions['class'] = CHtml::$errorCss;
}
}
$name = $htmlOptions['name'];
unset($htmlOptions['name']);
if (array_key_exists('uncheckValue', $htmlOptions)) {
$uncheck = $htmlOptions['uncheckValue'];
unset($htmlOptions['uncheckValue']);
} else {
$uncheck = '';
}
$hiddenOptions = isset($htmlOptions['id']) ? array('id' => CHtml::ID_PREFIX . $htmlOptions['id']) : array('id' => false);
$hidden = $uncheck !== null ? CHtml::hiddenField($name, $uncheck, $hiddenOptions) : '';
if (isset($htmlOptions['template'])) {
$template = $htmlOptions['template'];
} else {
$template = '<label class="{labelCssClass}">{input}{label}</label>';
}
unset($htmlOptions['template'], $htmlOptions['separator'], $htmlOptions['hint']);
if ($checkbox && substr($name, -2) !== '[]') {
$name .= '[]';
}
unset($htmlOptions['checkAll'], $htmlOptions['checkAllLast']);
$labelOptions = isset($htmlOptions['labelOptions']) ? $htmlOptions['labelOptions'] : array();
unset($htmlOptions['labelOptions']);
$items = array();
$baseID = CHtml::getIdByName($name);
$id = 0;
$method = $checkbox ? 'checkBox' : 'radioButton';
$labelCssClass = $checkbox ? 'checkbox' : 'radio';
if (isset($htmlOptions['inline'])) {
$labelCssClass .= '-inline';
unset($htmlOptions['inline']);
}
foreach ($data as $value => $label) {
$checked = !is_array($select) && !strcmp($value, $select) || is_array($select) && in_array($value, $select);
$htmlOptions['value'] = $value;
$htmlOptions['id'] = $baseID . '_' . $id++;
$option = CHtml::$method($name, $checked, $htmlOptions);
$label = CHtml::label($label, $htmlOptions['id'], $labelOptions);
$items[] = strtr($template, array('{labelCssClass}' => $labelCssClass, '{input}' => $option, '{label}' => $label));
}
return $hidden . implode('', $items);
}
示例8: array
">
<?php
$nscmaculopathy_html_options = array('options' => array());
foreach ($nsc_maculopathys as $macu) {
$nscmaculopathy_html_options['options'][(string) $macu->id] = array('data-booking' => $macu->booking_weeks, 'class' => $macu->class, 'data-code' => $macu->code);
}
echo CHtml::activeDropDownList($element, $side . '_nscmaculopathy_id', CHtml::listData($nsc_maculopathys, 'id', 'name'), $nscmaculopathy_html_options);
?>
</div>
<span class="grade-info-icon" data-info-type="maculopathy"><img src="<?php
echo $this->getAssetPathForElement($element);
?>
/img/icon_info.png" style="height:20px" /></span>
<div class="quicklook grade-info" style="display: none;">
<?php
$selected_value = CHtml::resolveValue($element, $side . '_nscmaculopathy_id');
if (!$selected_value && count($nsc_maculopathys)) {
$selected_value = $nsc_maculopathys[0]->id;
}
foreach ($nsc_maculopathys as $macu) {
$show_div = false;
if ($selected_value == $macu->id) {
$show_div = true;
}
echo '<div ' . ($show_div ? ' ' : 'style="display: none;" ') . 'class="' . CHtml::modelName($element) . '_' . $side . '_nscmaculopathy_desc desc" id="' . CHtml::modelName($element) . '_' . $side . '_nscmaculopathy_desc_' . $macu->code . '">' . $macu->description . '</div>';
}
?>
</div>
<!-- div containing the full list of descriptions for nsc maculopathy -->
<div id="<?php
echo CHtml::modelName($element) . '_' . $side . '_all_maculopathy_desc';
开发者ID:across-health,项目名称:OphCiExamination,代码行数:31,代码来源:form_Element_OphCiExamination_DRGrading_fields.php
示例9: testResolveValue
public function testResolveValue()
{
$testModel = new CHtmlTestFormModel();
$this->assertEquals('stringAttrValue', CHtml::resolveValue($testModel, 'stringAttr'));
$this->assertEquals('v1', CHtml::resolveValue($testModel, 'arrayAttr[k1]'));
$this->assertEquals('v2', CHtml::resolveValue($testModel, 'arrayAttr[k2]'));
$this->assertEquals($testModel->arrayAttr['k3'], CHtml::resolveValue($testModel, 'arrayAttr[k3]'));
$this->assertEquals('v4', CHtml::resolveValue($testModel, 'arrayAttr[k3][k4]'));
$this->assertEquals('v5', CHtml::resolveValue($testModel, 'arrayAttr[k3][k5]'));
$this->assertEquals('v6', CHtml::resolveValue($testModel, 'arrayAttr[k6]'));
$this->assertNull(CHtml::resolveValue($testModel, 'arrayAttr[k7]'));
$this->assertNull(CHtml::resolveValue($testModel, 'arrayAttr[k7][k8]'));
$this->assertEquals($testModel->arrayAttr, CHtml::resolveValue($testModel, '[ignored-part]arrayAttr'));
$this->assertEquals('v1', CHtml::resolveValue($testModel, '[ignored-part]arrayAttr[k1]'));
$this->assertEquals('v4', CHtml::resolveValue($testModel, '[ignore-this]arrayAttr[k3][k4]'));
}
示例10: activeUneditableField
/**
* Generates an uneditable input for a model attribute.
* @param CModel $model the data model.
* @param string $attribute the attribute.
* @param array $htmlOptions additional HTML attributes.
* @return string the generated input.
*/
public static function activeUneditableField($model, $attribute, $htmlOptions = array())
{
parent::resolveNameID($model, $attribute, $htmlOptions);
$value = parent::resolveValue($model, $attribute);
TbArray::removeValues(array('name', 'id'), $htmlOptions);
return self::uneditableField($value, $htmlOptions);
}
示例11: run
public function run()
{
$nameID = $this->resolveNameID();
$htmlOptions = $this->htmlOptions;
$htmlOptions['name'] = $nameID[0];
$htmlOptions['id'] = $nameID[1];
$htmlOptions['type'] = 'text/plain';
if (!isset($htmlOptions['value'])) {
$content = CHtml::resolveValue($this->model, $this->attribute);
} else {
$content = $htmlOptions['value'];
}
echo CHtml::tag('script', $htmlOptions, $content);
}
示例12: init
public function init()
{
parent::init();
// ensure necessary assets are loaded
// JJD 8/3/11 make EJuiAutoCompleteFkField work for child rows where attribute like [$i]FieldName
// get the ID which will be created for the actual field when it is rendered.
// don't let resolveNameID() change $this->attribute which is needed to generate the actual field
$attr = $this->attribute;
$tempHtmlOpts = array();
CHtml::resolveNameID($this->model, $attr, $tempHtmlOpts);
$id = $tempHtmlOpts['id'];
$this->_fieldID = $id;
$this->_saveID = $id . '_save';
$this->_lookupID = $id . '_lookup';
$related = $this->model->{$this->relName};
// get the related record
$value = CHtml::resolveValue($this->model, $this->attribute);
$this->_display = !empty($value) ? $related->{$this->displayAttr} : '';
// $this->_display=($value!==null ? $related->{$this->displayAttr} : ''); // nineinchnick comment #6809 handle zero as valid FK value. not sure works in all cases
if (!isset($this->options['minLength'])) {
$this->options['minLength'] = 2;
}
if (!isset($this->options['maxHeight'])) {
$this->options['maxHeight'] = '100';
}
$this->htmlOptions['size'] = $this->autoCompleteLength;
// fix problem with Chrome 10 validating maxLength for the auto-complete field
$this->htmlOptions['maxlength'] = $this->autoCompleteLength;
// setup javascript to do the work
$this->options['create'] = "js:function(event, ui){\$(this).val('" . addslashes($this->_display) . "');}";
// show initial display value
// after user picks from list, save the ID in model/attr field, and Value in _save field for redisplay
$this->options['select'] = "js:function(event, ui){\$('#" . $this->_fieldID . "').val(ui.item.id);\$('#" . $this->_saveID . "').val(ui.item.value);}";
// when the autoComplete field loses focus, refresh the field with current value of _save
// this is either the previous value if user didn't pick anything; or the new value if they did
$this->htmlOptions['onblur'] = "\$(this).val(\$('#" . $this->_saveID . "').val());";
}
示例13: activeInlineRadioButtonList
/**
* Generates a radio button list for a model attribute.
* The model attribute value is used as the selection.
* If the attribute has input error, the input field's CSS class will
* be appended with {@link errorCss}.
* @param CModel $model the data model
* @param string $attribute the attribute
* @param array $data value-label pairs used to generate the radio button list.
* Note, the values will be automatically HTML-encoded, while the labels will not.
* @param array $htmlOptions addtional HTML options. The options will be applied to
* each radio button input. The following special options are recognized:
* <ul>
* <li>template: string, specifies how each radio button is rendered. Defaults
* to "{input} {label}", where "{input}" will be replaced by the generated
* radio button input tag while "{label}" will be replaced by the corresponding radio button label.</li>
* <li>separator: string, specifies the string that separates the generated radio buttons. Defaults to new line (<br/>).</li>
* <li>encode: boolean, specifies whether to encode HTML-encode tag attributes and values. Defaults to true.</li>
* </ul>
* Since version 1.1.7, a special option named 'uncheckValue' is available that can be used to specify the value
* returned when the radio button is not checked. By default, this value is ''. Internally, a hidden field is
* rendered so that when the radio button is not checked, we can still obtain the posted uncheck value.
* If 'uncheckValue' is set as NULL, the hidden field will not be rendered.
* @return string the generated radio button list
* @see radioButtonList
*/
public static function activeInlineRadioButtonList($model, $attribute, $data, $htmlOptions = array())
{
CHtml::resolveNameID($model, $attribute, $htmlOptions);
$selection = CHtml::resolveValue($model, $attribute);
if ($model->hasErrors($attribute)) {
CHtml::addErrorCss($htmlOptions);
}
$name = self::popOption('name', $htmlOptions);
$unCheck = self::popOption('uncheckValue', $htmlOptions, '');
$hiddenOptions = isset($htmlOptions['id']) ? array('id' => CHtml::ID_PREFIX . $htmlOptions['id']) : array('id' => false);
$hidden = $unCheck !== null ? CHtml::hiddenField($name, $unCheck, $hiddenOptions) : '';
return $hidden . self::inlineRadioButtonList($name, $selection, $data, $htmlOptions);
}
示例14: array
<?php
$form = $this->beginWidget('booster.widgets.TbActiveForm', array('id' => 'info-form', 'enableAjaxValidation' => true, 'type' => 'horizontal', 'htmlOptions' => array('enctype' => "multipart/form-data", 'class' => 'well')));
$file = CHtml::resolveValue($model, 'resume_file');
?>
<fieldset>
<style type="text/css">.col-sm-5 {
padding-left: 0px;
}
.col-sm-4 {
padding-left: 0px;
}
</style>
<legend>
基本信息
<?php
if (!empty($file = CHtml::resolveValue($model, 'resume_file'))) {
$url = $this->createUrl('download', array('id' => $model->id));
$icon = CHtml::tag('i', array("style" => "", 'class' => 'glyphicon glyphicon-download text-primary'), '', true);
echo CHtml::link($icon, $url, array('style' => 'float:right'));
}
?>
<div class="progress progress-striped active" role="progressbar" style="display: inline;float:right;">
<div id="resume-file-bar" class="progress-bar progress-bar-success" style="width: 25%;">
<?php
echo CHtml::activeLabel($model, 'resume_file', array('style' => 'overflow: hidden;width: 100%;color:#000000;', 'id' => 'file-input-label', 'for' => 'file-input-button'));
?>
<?php
echo CHtml::activeFileField($model, 'resume_file', array('id' => 'file-input-button', 'style' => 'visibility: hidden;color:#000000', 'aria-valuemin' => 0, 'aria-valuemax' => 100, 'onchange' => 'void function(e){$("#ytfile-input-button").val(e.target.files[0].name);$("#resume-file-bar").width("100%");$("#file-input-label").text("简历文件:"+e.target.files[0].name);}(event)'));
?>
</div>
示例15: inputsList
/**
* Renders an input list.
* @param string $type the input type. Valid types are 'checkbox' and 'radio'.
* @param CModel $model the data model
* @param string $attribute the attribute
* @param array $data value-label pairs used to generate the radio button list.
* @param array $htmlOptions additional HTML options.
* @return string the generated input list.
* @since 0.9.5
*/
protected function inputsList($type, $model, $attribute, $data, $htmlOptions = array())
{
CHtml::resolveNameID($model, $attribute, $htmlOptions);
$selection = CHtml::resolveValue($model, $attribute);
if ($model->hasErrors($attribute)) {
if (isset($htmlOptions['class'])) {
$htmlOptions['class'] .= ' ' . CHtml::$errorCss;
} else {
$htmlOptions['class'] = CHtml::$errorCss;
}
}
$name = $htmlOptions['name'];
unset($htmlOptions['name']);
if (array_key_exists('uncheckValue', $htmlOptions)) {
$uncheck = $htmlOptions['uncheckValue'];
unset($htmlOptions['uncheckValue']);
} else {
$uncheck = '';
}
$hiddenOptions = isset($htmlOptions['id']) ? array('id' => CHtml::ID_PREFIX . $htmlOptions['id']) : array('id' => false);
$hidden = $uncheck !== null ? CHtml::hiddenField($name, $uncheck, $hiddenOptions) : '';
unset($htmlOptions['template'], $htmlOptions['separator'], $htmlOptions['labelOptions']);
$items = array();
$baseID = CHtml::getIdByName($name);
$id = 0;
$method = $type === 'checkbox' ? 'checkBox' : 'radioButton';
foreach ($data as $value => $label) {
$checked = !strcmp($value, $selection);
$htmlOptions['value'] = $value;
$htmlOptions['id'] = $baseID . '_' . $id++;
$option = CHtml::$method($name, $checked, $htmlOptions);
$items[] = '<label>' . $option . '<span>' . $label . '</span></label>';
}
return $hidden . '<ul class="inputs-list"><li>' . implode('</li><li>', $items) . '</li></ul>';
}