soukupj
(Info)
1
Hi,
how to universally errorSummary?
Example: I have different models in one view, $modelUser, $modelCars. I would call errorSummary the layout for a consistent display of errors.
I do not write
if ($modelUser) echo $form->errorSummary($modelUser);
if ($modelCars) echo $form->errorSummary($modelCars);
Optimally errorSummary () for all models in the current view.
Is there a solution?
thank you
anand.n
(Anand Neema2008)
2
I think you have to create two objects for both models and
then send that to model object to perticular view.
$model_first=new first();
$model_second=new second();
$this->render(‘Yourview’,array(‘model’=>$model_first,‘model’=>$model_second));
soukupj
(Info)
3
Yes, this is the standard solution when errorSummary in my view. But I’d like errorSummary level layout without having to identify specific models.
anand.n
(Anand Neema2008)
4
I think for this you have to include it in modules main file and import all models in that modules controller file.
i don’t know anthying about this.
mdomba
(Maurizio Domba Cerin)
5
[color="#008000"]NOTE: moved to proper section (General Discussion for Yii 1.1.x instead of Tips, Snippets and Tutorials)[/color]
joblo
(Joe)
6
- You can can show the errorSummary for an array of models;
$models = array($model1,$models2,…)
$form->errorSummary($models);
-
I think in your view you don’t work with a unknown list of models, you have to know which models to work with.
So why you want a universally solution?
But if you want you can try with the php function get_defined_vars(). But I wouldn’t do that, because of the ‘overhead’
$models = array();
foreach(get_defined_vars() as $var)
if($var instanceof CModel)
$models[] = array();
...
$form->errorSummary($models);
...