Probably the question is lame but I could not find the proper way of solving this case. And the case is:
I have one page with several forms and I need to separate the save functions from the action function and still get everything validated.
Ex:
public function actionAdmin(){
if(isset($_POST['Post'])){
$this->_addPost();
}
if(isset($_POST['Blog'])){
$this->_addBlog();
}
}
private function _addPost(){
$post=new Post('insert');
if($post->save()){
$this->redirect(Yii::app()->request->urlReferrer);
}
}
private function _addBlog(){
$blog=new Blog('insert');
if($blog->save()){
$this->redirect(Yii::app()->request->urlReferrer);
}
}
But to get both validated I need to pass the $post and $blog to be rendered.
Another option is to make separated actions for adding Blog and Post and to change the default form action. So the Post form will go to post_add, and the other one to blog_add. But here is the same case => can not validate the form and if the input is not valid either dont get redirected or if redirected no error massages are set.
Can it be solved with Yii?