getErrors() as $attribute=>$errors)
{
foreach($errors as $error)
{
if($error!='')
$content.="
$error\n";
}
}
}
if($content!=='')
{
$header=''.Yii::t('yii','Please fix the following input errors:').'
';
return self::tag('div',array('id'=>self::$errorSummaryCss),$header."\n\n$content
".$footer);
}
else
return '';
}
public static function activeLabel($model,$attribute,$htmlOptions=array())
{
$for=self::getIdByName(self::resolveName($model,$attribute));
if(isset($htmlOptions['label']))
{
$label=$htmlOptions['label'];
unset($htmlOptions['label']);
}
else
$label=$model->getAttributeLabel($attribute);
return self::label($label,$for,$htmlOptions);
}
public static function activeLabelEx($model,$attribute,$htmlOptions=array())
{
$realAttribute=$attribute;
self::resolveName($model,$attribute); // strip off square brackets if any
$htmlOptions['required']=$model->isAttributeRequired($attribute);
return self::activeLabel($model,$realAttribute,$htmlOptions);
}
public static function submitButton($label='submit',$htmlOptions=array())
{
$htmlOptions['type']='submit';
$htmlOptions = self::addUniFormClass($htmlOptions, 'submitButton');
return self::button($label,$htmlOptions);
}
public static function resetButton($label='reset',$htmlOptions=array())
{
$htmlOptions['type']='reset';
$htmlOptions = self::addUniFormClass($htmlOptions, 'resetButton');
// Workaround for IE alignment
return self::tag('div', array('class'=>'resetButton', self::button($label, $htmlOptions)));
}
public static function activeTextField($model,$attribute,$htmlOptions=array())
{
self::resolveNameID($model,$attribute,$htmlOptions);
self::clientChange('change',$htmlOptions);
$htmlOptions = self::addUniFormClass($htmlOptions, 'textInput');
$htmlOptions = self::addUniFormClass($htmlOptions, 'tweetnews-input');
return self::activeInputField('text',$model,$attribute,$htmlOptions);
}
protected static function activeInputField($type,$model,$attribute,$htmlOptions)
{
$htmlOptions['type']=$type;
if($type==='file')
unset($htmlOptions['value']);
else if(!isset($htmlOptions['value']))
$htmlOptions['value']=$model->$attribute;
return self::tag('input',$htmlOptions);
}
public static function openActiveCtrlHolder($model,$attribute,$htmlOptions=array())
{
$opentag='';
if($model->hasErrors($attribute))
{
self::addErrorCss($htmlOptions);
$opentag = ''.$model->getError($attribute)."
\n";
}
$opentag = self::openCtrlHolder($htmlOptions)."\n".$opentag;
return $opentag;
}
public static function openCtrlHolder($htmlOptions=array())
{
if (isset($htmlOptions['class']))
$htmlOptions['class'] = $htmlOptions['class'].' ctrlHolder';
else
$htmlOptions['class'] = 'ctrlHolder';
return self::openTag('div', $htmlOptions);
}
public static function closeCtrlHolder()
{
return "".self::closeTag('div')."\n";
}
protected static function addUniFormClass($htmlOptions, $class)
{
if (isset($htmlOptions['class']))
$htmlOptions['class'] = $htmlOptions['class'].' '.$class;
else
$htmlOptions['class'] = $class;
return $htmlOptions;
}
}