本文整理汇总了PHP中TbHtml::error方法的典型用法代码示例。如果您正苦于以下问题:PHP TbHtml::error方法的具体用法?PHP TbHtml::error怎么用?PHP TbHtml::error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TbHtml
的用法示例。
在下文中一共展示了TbHtml::error方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: error
/**
* Displays the first validation error for a model attribute.
* @param CModel $model the data model
* @param string $attribute the attribute name
* @param array $htmlOptions additional HTML attributes to be rendered in the container div tag.
* @param boolean $enableAjaxValidation whether to enable AJAX validation for the specified attribute.
* @param boolean $enableClientValidation whether to enable client-side validation for the specified attribute.
* @return string the validation result (error display or success message).
*/
public function error($model, $attribute, $htmlOptions = array(), $enableAjaxValidation = true, $enableClientValidation = true)
{
if (!$this->enableAjaxValidation) {
$enableAjaxValidation = false;
}
if (!$this->enableClientValidation) {
$enableClientValidation = false;
}
if (!$enableAjaxValidation && !$enableClientValidation) {
return TbHtml::error($model, $attribute, $htmlOptions);
}
$id = CHtml::activeId($model, $attribute);
$inputID = TbArray::getValue('inputID', $htmlOptions, $id);
unset($htmlOptions['inputID']);
TbArray::defaultValue('id', $inputID . '_em_', $htmlOptions);
$option = array('id' => $id, 'inputID' => $inputID, 'errorID' => $htmlOptions['id'], 'model' => get_class($model), 'name' => $attribute, 'enableAjaxValidation' => $enableAjaxValidation, 'inputContainer' => 'div.control-group');
$optionNames = array('validationDelay', 'validateOnChange', 'validateOnType', 'hideErrorMessage', 'inputContainer', 'errorCssClass', 'successCssClass', 'validatingCssClass', 'beforeValidateAttribute', 'afterValidateAttribute');
foreach ($optionNames as $name) {
if (isset($htmlOptions[$name])) {
$option[$name] = TbArray::popValue($name, $htmlOptions);
}
}
if ($model instanceof CActiveRecord && !$model->isNewRecord) {
$option['status'] = 1;
}
if ($enableClientValidation) {
$validators = TbArray::getValue('clientValidation', $htmlOptions, array());
$attributeName = $attribute;
if (($pos = strrpos($attribute, ']')) !== false && $pos !== strlen($attribute) - 1) {
$attributeName = substr($attribute, $pos + 1);
}
foreach ($model->getValidators($attributeName) as $validator) {
if ($validator->enableClientValidation) {
if (($js = $validator->clientValidateAttribute($model, $attributeName)) != '') {
$validators[] = $js;
}
}
}
if ($validators !== array()) {
$option['clientValidation'] = "js:function(value, messages, attribute) {\n" . implode("\n", $validators) . "\n}";
}
}
$html = TbHtml::error($model, $attribute, $htmlOptions);
if ($html === '') {
$htmlOptions['type'] = $this->helpType;
TbHtml::addCssStyle('display:none', $htmlOptions);
$html = TbHtml::help('', $htmlOptions);
}
$this->attributes[$inputID] = $option;
return $html;
}
示例2: testError
public function testError()
{
$I = $this->codeGuy;
$model = new Dummy();
$model->addError('text', 'Error text');
$html = TbHtml::error($model, 'text', array('class' => 'error'));
$span = $I->createNode($html, 'span.help-inline');
$I->seeNodeCssClass($span, 'error');
$I->seeNodeText($span, 'Error text');
}
示例3: array
'showAnim'=>'fold',
'showOn'=>'both',//focus,button,both
'changeMonth'=>true,
'changeYear'=>true,
'yearRange'=>'-100:+0',//last hundred years
'buttonText'=>'Please select date',
'buttonImage'=>Yii::app()->request->baseUrl."/images/calendar.png",
'buttonImageOnly'=>true,
'dateFormat'=>'yy-mm-dd',
),
'htmlOptions'=>array(
'style'=>'height:25px;',
),
));
?>
<?php echo TbHtml::error($model,'dateTo'); ?>
</td>
<td><?php echo $form->textFieldControlGroup($model,'meeting_no'); ?></td>
</tr>
<tr>
<td><?php echo $form->dropDownListControlGroup($model,'responsible_mda_id',
TbHtml::listData(Mda::model()->findAll(),"id","description"),
array(
'empty'=>'--select--'
)); ?>
</td>
<td></td>
<td></td>
<td></td>
</tr>
示例4:
'showAnim'=>'fold',
'showOn'=>'both',//focus,button,both
'changeMonth'=>true,
'changeYear'=>true,
'yearRange'=>'-5:+100',//next hundred years
'buttonText'=>'Please select date',
'buttonImage'=>Yii::app()->request->baseUrl."/images/calendar.png",
'buttonImageOnly'=>true,
'dateFormat'=>'yy-mm-dd',
),
'htmlOptions'=>array(
'style'=>'height:25px;',
),
));
?>
<?php echo TbHtml::error($model,'deadline'); ?>
<div class="form-actions">
<?php echo TbHtml::submitButton('Save',array(
'color'=>TbHtml::BUTTON_COLOR_SUCCESS,
'size'=>TbHtml::BUTTON_SIZE_DEFAULT,
)); ?>
<?php echo TbHtml::button('Close',array(
'color'=>TbHtml::BUTTON_COLOR_DEFAULT,
'size'=>TbHtml::BUTTON_SIZE_DEFAULT,
'id'=>'close-button'
)); ?>
</div>
<?php $this->endWidget(); ?>
示例5: array
?>
<p class="hint"><?php
echo UserModule::t('Display order of fields.');
?>
</p>
</div>
<div class="row visible">
<?php
echo TbHtml::activeLabelEx($model, 'visible');
?>
<?php
echo TbHtml::activeDropDownList($model, 'visible', ProfileField::itemAlias('visible'));
?>
<?php
echo TbHtml::error($model, 'visible');
?>
</div>
<div class="row buttons">
<?php
echo TbHtml::button($model->isNewRecord ? UserModule::t('Create') : UserModule::t('Save'), array('color' => TbHtml::BUTTON_COLOR_SUCCESS, 'submit' => ''));
?>
</div>
<?php
echo TbHtml::endForm();
?>
</div><!-- form -->
<div id="dialog-form" title="<?php