It currently outputs the following:
Please fix the following input errors:
Name cannot be blank.
Phone cannot be blank.
I want it to output the following:
Error: Name cannot be blank, Phone cannot be blank.
How can I do this?
It currently outputs the following:
Please fix the following input errors:
Name cannot be blank.
Phone cannot be blank.
I want it to output the following:
Error: Name cannot be blank, Phone cannot be blank.
How can I do this?
Override CHtml::errorSummary() ?
OK well I tried modifying header & footer values but that doesn’t let me put the error “fields” on one line.
You can use CSS to achieve that effect.
div.form.errorSummary ul li
{
display: inline;
list-style-type: none;
}
and if you want take off the header (Please fix the following input errors:) and the footer in that order
<?php echo $form->errorSummary($model,"",""); ?>
for more information check framework/web/helpers/CHtml.php file. ref: http://www.yiiframew…rSummary-detail
public static function errorSummary($model,$header=null,$footer=null,$htmlOptions=array())
{
$content='';
if(!is_array($model))
$model=array($model);
if(isset($htmlOptions['firstError']))
{
$firstError=$htmlOptions['firstError'];
unset($htmlOptions['firstError']);
}
else
$firstError=false;
foreach($model as $m)
{
foreach($m->getErrors() as $errors)
{
foreach($errors as $error)
{
if($error!='')
$content.="<li>$error</li>\n";
if($firstError)
break;
}
}
}
if($content!=='')
{
if($header===null)
$header='<p>'.Yii::t('yii','Please fix the following input errors:').'</p>';
if(!isset($htmlOptions['class']))
$htmlOptions['class']=self::$errorSummaryCss;
return self::tag('div',$htmlOptions,$header."\n<ul>\n$content</ul>".$footer);
}
else
return '';
}