Solution here: http://www.yiiframework.com/forum/index.php?/topic/8219-solved-ajax-form-submission/
plus i put the action in the wrong controller…
Hi there,
i’m having nice first days using Yii but have some troubles with getting things that i used to write ‘from the finger’ .
Here is the background for my question:
I created a ‘project’ model,controller and view (works fine) and in the ‘views/project/_form.php’ i put an ajax link that displays a partial view : a form that belongs to another model, named ‘picture’.
So, the ‘project’ _from.php has this inside:
<?php
echo CHtml::ajaxLink('Add picture', array('projekt/addPicture'), array( 'update'=>'#req_res'));
?>
<div id="req_res">...</div>
the /project/addPicture action successfully shows the form using such code:
public function actionAddPicture()
{
$model=new Picture;
$this->renderPartial('/projekt/_addPicture', array('model'=>$model));
Yii::app()->end();
}
and the ‘_addPicture.php’ file in the /projekt/view folder has a “cactiveform” inside, loading the ‘$model’ correctly (i can see my data stroed in the DB etc.)
Problem:
when i hit ‘save’ on the newly generated form, Yii sends me to a new white page containing again this form instead of saving it. Here’s the URL Yii sends me to:
http://localhost/projekt/addPicture?_=1304644637668
i am vaguely aware that it may have something to do with me not telling Yii which controller to use (?) but i don’t know how to specify the controller (if this is the case)
Can you point me to some direction here? Thank you