Adderror In Beforesave Not Work When $Model->Save() In Loop

while insert multiple data, then $this->addError stop working.

for example in Controller:

foreach($roomfacilty as $data)





			$model->hostel_room_facility_id = $data;		

            		$model->hostel_room_category_facility_creation_date = new CDbExpression('NOW()');



when as above data insert then it check validation properly in beforeSave() but not give error message(which is display through addError).


There is no problem regarding addError. But main problem is redirection.

Please use following tips:

$var = $model->save();

you store value of $model->save(); in $var. And if it return true then redirect otherwise render your _form view.



Ravi Bhalodiya.

RudraSoftech Team

Thanks its solve my problem.:slight_smile:

[color="#006400"]/* moved from Bug Discussions */[/color]