本文整理汇总了PHP中CHtml::error方法的典型用法代码示例。如果您正苦于以下问题:PHP CHtml::error方法的具体用法?PHP CHtml::error怎么用?PHP CHtml::error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CHtml
的用法示例。
在下文中一共展示了CHtml::error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$model = $this->model;
$cities = $this->cities;
$locations = $model->locations;
if (empty($locations)) {
$location = new CompetitionLocation();
$locations = array($location->attributes);
}
//tab
echo CHtml::openTag('ul', array('class' => 'nav nav-tabs', 'role' => 'tablist'));
foreach ($locations as $key => $location) {
$index = $key + 1;
echo CHtml::tag('li', array('class' => $key == 0 ? 'active' : ''), CHtml::tag('a', array('href' => '#location-' . $index, 'role' => 'tab', 'data-toggle' => 'tab'), '地址' . $index . ($key == 0 ? '<span class="required">*</span></a>' : '')));
}
echo '<li><a id="addLocation"><i class="fa fa-plus"></i> 添加</a></li>';
echo CHtml::closeTag('ul');
echo '<div class="text-danger col-lg-12">地址1必填,除非多地点比赛,否则请只填写一个地址,留空即可删去多余地址。</div>';
//tab content
echo CHtml::openTag('div', array('class' => 'tab-content locations'));
foreach ($locations as $key => $location) {
$index = $key + 1;
echo CHtml::openTag('div', array('class' => 'tab-pane location' . ($key == 0 ? ' active' : ''), 'id' => 'location-' . $index));
echo Html::formGroup($model, 'locations[province_id][]', array('class' => 'col-lg-6'), CHtml::label('省份', false), CHtml::dropDownList(CHtml::activeName($model, 'locations[province_id][]'), $location['province_id'], Region::getProvinces(false), array('class' => 'form-control province', 'prompt' => '')), CHtml::error($model, 'locations.province_id.' . $key, array('class' => 'text-danger')));
echo Html::formGroup($model, 'locations[city_id][]', array('class' => 'col-lg-6'), CHtml::label('城市', false), CHtml::dropDownList(CHtml::activeName($model, 'locations[city_id][]'), $location['city_id'], isset($cities[$location['province_id']]) ? $cities[$location['province_id']] : array(), array('class' => 'form-control city', 'prompt' => '')), CHtml::error($model, 'locations.city_id.' . $key, array('class' => 'text-danger')));
echo Html::formGroup($model, 'locations[venue_zh][]', array('class' => 'col-lg-12'), CHtml::label('中文地址', false), CHtml::textField(CHtml::activeName($model, 'locations[venue_zh][]'), $location['venue_zh'], array('class' => 'form-control')), CHtml::error($model, 'locations.venue_zh.' . $key, array('class' => 'text-danger')));
echo Html::formGroup($model, 'locations[venue][]', array('class' => 'col-lg-12'), CHtml::label('英文地址', false), CHtml::textField(CHtml::activeName($model, 'locations[venue][]'), $location['venue'], array('class' => 'form-control')), CHtml::error($model, 'locations.venue.' . $key, array('class' => 'text-danger')));
echo CHtml::closeTag('div');
}
echo CHtml::closeTag('div');
Yii::app()->clientScript->registerScript('MultiLocations', <<<EOT
\$(document).on('click', '#addLocation', function() {
var location = \$('.location:last').clone();
var index = \$('.location').length + 1;
var tab = \$('<a role="tab" data-toggle="tab">').attr('href', '#location-' + index).text('地址' + index);
location.appendTo(\$('.locations'));
location.find('.province').val('').trigger('change');
location.find('input').val('');
location.attr('id', 'location-' + index).removeClass('active');
\$('<li>').append(
tab
).insertBefore(\$('#addLocation').parent());
tab.tab('show');
});
EOT
);
}
示例2: actionCreate
public function actionCreate()
{
$head = new CalculationHead();
if (isset($_POST['CalculationHead'])) {
$head->attributes = $_POST['CalculationHead'];
$head->scenario = $head->project_type;
$valid = $head->validate();
$valid2 = true;
if (isset($_POST['CalculationDetail'])) {
$det = array();
$i = 0;
$errorDet = "";
$detail = $_POST['CalculationDetail'];
foreach ($detail as $data) {
$det[$i] = new CalculationDetail();
$det[$i]->area_type = $data['area_type'];
$det[$i]->area_size = $data['area_size'];
$det[$i]->head_id = $i;
if (!$det[$i]->validate()) {
$errorDet = $det[$i];
$valid2 = false;
break;
}
$i += 1;
}
}
if ($valid && $valid2) {
$head->datetime = new CDbExpression('NOW()');
$head->deadline = date('Y-m-d', mktime(0, 0, 0, $head->month, $head->date, $head->year));
if ($head->save()) {
if (isset($det)) {
foreach ($det as $d) {
$d->head_id = $head->id;
$d->save();
}
}
$this->SendMail($head, $det);
echo CJSON::encode(array('result' => 'success'));
}
} else {
//print_r($head->getErrors());
echo CJSON::encode(array('result' => 'failed', 'vc' => CHtml::error($head, 'views_count'), 'ia' => CHtml::error($head, 'interior_areas'), 'nv' => CHtml::error($head, 'number_views'), 'sop' => CHtml::error($head, 'project_style'), 'pt' => CHtml::error($head, 'product_type'), 'date' => CHtml::error($head, 'date'), 'month' => CHtml::error($head, 'month'), 'year' => CHtml::error($head, 'year'), 'ref' => CHtml::error($head, 'reference'), 'email' => CHtml::error($head, 'email'), 'area_type' => $errorDet ? CHtml::error($errorDet, 'area_type') : "", 'area_size' => $errorDet ? CHtml::error($errorDet, 'area_size') : "", 'det_idx' => $errorDet ? $errorDet->head_id + 1 : 0));
}
}
}
示例3:
* <?php echo $form->error($model,'lastName'); ?>
* </div>
*
* <?php $this->endWidget(); ?>
* </pre>
*
* To respond to the AJAX validation requests, we need the following class code:
* <pre>
* public function actionCreate()
* {
* $model=new User;
* $this->performAjaxValidation($model);
* if(isset($_POST['User']))
* {
* $model->attributes=$_POST['User'];
* if($model->save())
* $this->redirect('index');
* }
* $this->render('create',array('model'=>$model));
* }
*
* protected function performAjaxValidation($model)
* {
* if(isset($_POST['ajax']) && $_POST['ajax']==='user-form')
* {
* echo CActiveForm::validate($model);
* Yii::app()->end();
* }
* }
* </pre>
* The method <code>performAjaxValidation</code> is the main extra code we add to our
* traditional model creation action code. In this method, we check if the request
* is submitted via AJAX by the 'user-form'. If so, we validate the model and return
* the validation results. We may call the same method in model update action.
*
* On the client side, an input field may be in one of the four states: initial (not validated),
* validating, error and success. To differentiate these states, CActiveForm automatically
示例4: array
<?php
/**
* @var $this YdAccountController
* @var $user YdAccountRecover
* @var $recaptcha string
*
* @author Brett O'Donnell <cornernote@gmail.com>
* @author Zain Ul abidin <zainengineer@gmail.com>
* @copyright 2013 Mr PHP
* @link https://github.com/cornernote/yii-dressing
* @license BSD-3-Clause https://raw.github.com/cornernote/yii-dressing/master/license.txt
*/
$this->pageTitle = Yii::t('dressing', 'Recover Password');
/** @var YdActiveForm $form */
$form = $this->beginWidget('dressing.widgets.YdActiveForm', array('id' => 'recover-form', 'type' => 'horizontal'));
echo $form->beginModalWrap();
echo $form->errorSummary($user);
echo $form->textFieldRow($user, 'username_or_email');
if ($recaptcha) {
echo CHtml::activeLabel($user, 'recaptcha');
$this->widget('dressing.widgets.YdReCaptchaInput', array('model' => $user));
echo CHtml::error($user, 'recaptcha');
}
echo $form->endModalWrap();
echo '<div class="' . $form->getSubmitRowClass() . '">';
$this->widget('bootstrap.widgets.TbButton', array('label' => Yii::t('dressing', 'Recover'), 'type' => 'primary', 'buttonType' => 'submit'));
echo ' ';
$this->widget('bootstrap.widgets.TbButton', array('label' => Yii::t('dressing', 'Back to Login'), 'url' => array('/account/login')));
echo '</div>';
$this->endWidget();
示例5: array
?>
:</th>
<th><?php
echo CHtml::activeLabel($form, 'lng');
?>
:</th>
</tr>
<tr>
<td><?php
echo CHtml::activeTextField($form, 'lat', array('style' => 'width: 130px;'));
echo CHtml::error($form, 'lat');
?>
</td>
<td><?php
echo CHtml::activeTextField($form, 'lng', array('style' => 'width: 130px;'));
echo CHtml::error($form, 'lng');
?>
</td>
</tr>
<tr>
<td colspan="2">
You change the coordinates by moving the pin.
<div id="map_canvas" style="width: 386px; height: 300px; border: 1px solid #c0c0c0;"></div>
</td>
</tr>
</table>
<div style="clear: both;"></div>
<?php
echo CHtml::endForm();
?>
示例6: error
/**
* Displays the first validation error for a model attribute.
* This is similar to {@link CHtml::error} except that it registers the model attribute
* so that if its value is changed by users, an AJAX validation may be triggered.
* @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.
* Besides all those options available in {@link CHtml::error}, the following options are recognized in addition:
* <ul>
* <li>validationDelay</li>
* <li>validateOnChange</li>
* <li>validateOnType</li>
* <li>hideErrorMessage</li>
* <li>inputContainer</li>
* <li>errorCssClass</li>
* <li>successCssClass</li>
* <li>validatingCssClass</li>
* <li>beforeValidateAttribute</li>
* <li>afterValidateAttribute</li>
* </ul>
* These options override the corresponding options as declared in {@link options} for this
* particular model attribute. For more details about these options, please refer to {@link clientOptions}.
* Note that these options are only used when {@link enableAjaxValidation} or {@link enableClientValidation}
* is set true.
*
* When client-side validation is enabled, an option named "clientValidation" is also recognized.
* This option should take a piece of JavaScript code to perform client-side validation. In the code,
* the variables are predefined:
* <ul>
* <li>value: the current input value associated with this attribute.</li>
* <li>messages: an array that may be appended with new error messages for the attribute.</li>
* <li>attribute: a data structure keeping all client-side options for the attribute</li>
* </ul>
* @param boolean $enableAjaxValidation whether to enable AJAX validation for the specified attribute.
* Note that in order to enable AJAX validation, both {@link enableAjaxValidation} and this parameter
* must be true.
* @param boolean $enableClientValidation whether to enable client-side validation for the specified attribute.
* Note that in order to enable client-side validation, both {@link enableClientValidation} and this parameter
* must be true. This parameter has been available since version 1.1.7.
* @return string the validation result (error display or success message).
* @see CHtml::error
*/
public function error($model, $attribute, $htmlOptions = array(), $enableAjaxValidation = true, $enableClientValidation = true)
{
if (!$this->enableAjaxValidation) {
$enableAjaxValidation = false;
}
if (!$this->enableClientValidation) {
$enableClientValidation = false;
}
if (!isset($htmlOptions['class'])) {
$htmlOptions['class'] = $this->errorMessageCssClass;
}
if (!$enableAjaxValidation && !$enableClientValidation) {
return CHtml::error($model, $attribute, $htmlOptions);
}
$id = CHtml::activeId($model, $attribute);
$inputID = isset($htmlOptions['inputID']) ? $htmlOptions['inputID'] : $id;
unset($htmlOptions['inputID']);
if (!isset($htmlOptions['id'])) {
$htmlOptions['id'] = $inputID . '_em_';
}
$option = array('id' => $id, 'inputID' => $inputID, 'errorID' => $htmlOptions['id'], 'model' => get_class($model), 'name' => $attribute, 'enableAjaxValidation' => $enableAjaxValidation);
$optionNames = array('validationDelay', 'validateOnChange', 'validateOnType', 'hideErrorMessage', 'inputContainer', 'errorCssClass', 'successCssClass', 'validatingCssClass', 'beforeValidateAttribute', 'afterValidateAttribute');
foreach ($optionNames as $name) {
if (isset($htmlOptions[$name])) {
$option[$name] = $htmlOptions[$name];
unset($htmlOptions[$name]);
}
}
if ($model instanceof CActiveRecord && !$model->isNewRecord) {
$option['status'] = 1;
}
if ($enableClientValidation) {
$validators = isset($htmlOptions['clientValidation']) ? array($htmlOptions['clientValidation']) : 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'] = new CJavaScriptExpression("function(value, messages, attribute) {\n" . implode("\n", $validators) . "\n}");
}
}
$html = CHtml::error($model, $attribute, $htmlOptions);
if ($html === '') {
if (isset($htmlOptions['style'])) {
$htmlOptions['style'] = rtrim($htmlOptions['style'], ';') . ';display:none';
} else {
$htmlOptions['style'] = 'display:none';
}
$html = CHtml::tag('div', $htmlOptions, '');
}
$this->attributes[$inputID] = $option;
//.........这里部分代码省略.........
示例7: array
<?php
echo CHtml::error($salary, 'level_id');
?>
</div>
</div>
<div class="form-group">
<?php
echo CHtml::activeLabelEx($salary, 'grade_id', array('class' => $label_class));
?>
<div class="col-md-6 col-xs-12">
<?php
echo CHtml::activeDropDownList($salary, 'grade_id', CHtml::listData(ReferenceGrades::model()->findAll(), 'id', 'grade'), array('data-placeholder' => at('Please select one...'), 'prompt' => '', 'class' => 'validate[required] form-control select', 'id' => 'field_grade_id'));
?>
<?php
echo CHtml::error($salary, 'grade_id');
?>
</div>
</div>
</div>
<div class="panel-footer">
<?php
/*echo CHtml::button('Clear Form', array('class'=>'btn btn-default'));*/
?>
<?php
// echo CHtml::submitButton('Save', array('class'=>'btn btn-primary pull-right'));
?>
<a class="btn btn-primary pull-right" href="#" id="btnUpgradeSalary">Save</a>
</div>
</div>
示例8: array
<?php
echo CHtml::error($model, 'group_close');
?>
</div>
</div>
<div class="form-group">
<?php
echo CHtml::activeLabelEx($model, 'sort_ord', array('class' => $label_class));
?>
<div class="col-md-6 col-xs-12">
<?php
echo CHtml::activeTextField($model, 'sort_ord', array('class' => 'validate[custom[number]] form-control'));
?>
<?php
echo CHtml::error($model, 'sort_ord');
?>
</div>
</div>
</div>
<div class="panel-footer">
<?php
/*echo CHtml::button('Clear Form', array('class'=>'btn btn-default'));*/
?>
<?php
echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save', array('class' => 'btn btn-primary pull-right'));
?>
</div>
</div>
</div>
示例9:
?>
<?php
echo CHtml::activeTextField($user, 'username');
echo CHtml::error($user, 'username');
?>
</div>
<div class="simple">
<?php
echo CHtml::activeLabel($user, 'password');
?>
<?php
echo CHtml::activePasswordField($user, 'password');
echo CHtml::error($user, 'password');
?>
</div>
<div class="action">
<?php
if ($this->enableRememberMe) {
echo CHtml::activeCheckBox($user, 'rememberMe');
?>
Remember me next time<br/>
<?php
}
echo CHtml::submitButton('Login');
?>
</div>
示例10: array
<td> </td>
<td class="date">
<?php
echo CHtml::activeTextField($form, 'date_to', array('class' => 'date-pick input-calendar'));
?>
<?php
echo CHtml::error($form, 'date_to');
?>
</td>
<td class="time">
<?php
echo CHtml::activeTextField($form, 'time_to', array('style' => 'width: 50px;'));
?>
<?php
echo CHtml::error($form, 'time_to');
?>
</td>
<td> </td>
<td class="buttons">
<input type="submit" name="filter" value="<?php
echo It::t('site_label', 'do_filter');
?>
" />
<input type="submit" name="clear" value="<?php
echo It::t('site_label', 'do_reset');
?>
" />
</td>
</tr>
示例11: array
echo Yum::t('Your Avatar image');
echo '</h2>';
echo $model->getAvatar();
} else {
echo Yum::t('You do not have set an avatar image yet');
}
}
echo '<br />';
if (Yum::module('avatar')->avatarMaxWidth != 0) {
echo '<p>' . Yum::t('The image should have at least 50px and a maximum of 200px in width and height. Supported filetypes are .jpg, .gif and .png') . '</p>';
}
echo CHtml::errorSummary($model);
echo CHtml::beginForm(array('//avatar/avatar/editAvatar', 'id' => $model->id), 'POST', array('enctype' => 'multipart/form-data'));
echo '<div class="row">';
echo CHtml::activeLabelEx($model, 'avatar');
echo CHtml::activeFileField($model, 'avatar');
echo CHtml::error($model, 'avatar');
echo '</div>';
if (Yum::module('avatar')->enableGravatar) {
echo CHtml::submitButton(Yum::t('Upload avatar'), array('class' => 'btn btn-primary left_button'));
}
echo '<br />';
echo CHtml::link(Yum::t('Use Gravatar'), array('//avatar/avatar/enableGravatar', 'id' => $model->id), array('class' => 'btn btn-primary left_button'));
echo ' ';
echo CHtml::link(Yum::t('Remove Avatar'), array('//avatar/avatar/removeAvatar', 'id' => $model->id), array('class' => 'btn btn-primary left_button'));
echo CHtml::endForm();
?>
</div>
</div>
示例12:
<td><?php
echo CHtml::error($form, 'username');
?>
</td>
</tr>
<tr>
<th><?php
echo CHtml::activeLabel($form, 'password');
?>
</th>
<td><?php
echo CHtml::activePasswordField($form, 'password');
?>
</td>
<td><?php
echo CHtml::error($form, 'password');
?>
</td>
</tr>
<tr class="bottom">
<td><?php
echo CHtml::activeCheckBox($form, 'rememberMe');
?>
<?php
echo CHtml::activeLabel($form, 'rememberMe');
?>
</td>
<td><?php
echo CHtml::submitButton('Login');
?>
</td>
示例13: array
<?php
echo CHtml::error($model, 'doctor_letter_proof');
?>
</div>
</div>
<div class="form-group">
<?php
echo CHtml::activeLabelEx($model, 'number_of_hours', array('class' => $label_class));
?>
<div class="col-md-6 col-xs-12">
<?php
echo CHtml::activeTextField($model, 'number_of_hours', array('class' => 'validate[required] form-control', 'style' => 'width:100px;', 'value' => ''));
?>
<?php
echo CHtml::error($model, 'number_of_hours');
?>
</div>
</div>
</div>
<input value="save" name="command" id="hiddenInputCommand" hidden>
<div class="panel-footer">
<?php
/*echo CHtml::button('Clear Form', array('class'=>'btn btn-default'));*/
?>
<span class="pull-right">
<?php
示例14: array
<?php
if ($model->id) {
?>
<h3><?php
echo CartModule::t('Add Relation', 'product');
?>
</h3>
<div class="row">
<?php
echo CHtml::activeLabelEx($newRelation, 'pr_id', array('label' => CartModule::t('Product Id', 'product')));
?>
<?php
echo CHtml::activeTextField($newRelation, 'pr_id');
?>
<?php
echo CHtml::error($newRelation, 'pr_id');
?>
</div>
<?php
}
if ($model->relation) {
echo '<h2>' . CartModule::t('Relation Products', 'product') . '</h2>';
}
//echo "<pre>"; print_r($model->relation); die();
foreach ($model->relation as $n => $m) {
?>
<div class="row">
<div class="photo"><?php
if ($m->photo) {
echo CHtml::link($m->photo->img(array("w" => "100")), array('view', 'id' => $m->id));
}
示例15: array
<?php
echo CHtml::error($model, 'alergy');
?>
</div>
</div>
<div class="form-group">
<?php
echo CHtml::activeLabelEx($model, 'mcu_status', array('class' => $label_class));
?>
<div class="col-md-6 col-xs-12">
<?php
echo CHtml::activeRadioButtonList($model, 'mcu_status', MastersEmployeeMcu::model()->getStatuses(), array('class' => 'validate[required] form-control iradio', 'separator' => ' '));
?>
<?php
echo CHtml::error($model, 'mcu_status');
?>
</div>
</div>
</div>
<div class="panel-footer">
<?php
/*echo CHtml::button('Clear Form', array('class'=>'btn btn-default'));*/
?>
<?php
echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save', array('class' => 'btn btn-primary pull-right'));
?>
</div>
</div>
</div>