ouhman
(Ouhman)
1
Hello,
I just have a quick question.
I am in the z controller and would like to call y method in y object.
I have tried that way but it does not work :
So in Z controller:
y = new y;
y->loady(id)->delete();
I have the message that the method is not exists.
How can I call y methods from z controller?
ouhman
(Ouhman)
3
Yes, I have tried that.
Here is the following code.
public function actiondeleteLanguage()
{
if(Yii::app()->request->isAjaxRequest)
{
$cv_langue = new cv_langue;
$cv_langue->loadcv_langue($_POST['cv_texte']['id_cv_langue'])->delete();
{
$cv_langue=cv_langue::model()->findAll();
foreach($cv_langue as $value){
echo '<option value="'.$value->id_langue.'">'.$value->titre.'</option>';
}
}
}
}
But I have the following message :
cv_langue does not have a method named loadcv_langue.
qiang
(Qiang Xue)
4
The error message is clear. Your cv_langue class doesn't have a method named "loadcv_langue".
ouhman
(Ouhman)
5
The method is exisiting that the point I do not understand…
In my cv_langue controler:
public function loadcv_langue($id=null)
{
if($this->_cv_langue===null)
{
if($id!==null || isset($_GET['id']))
$this->_cv_langue=cv_langue::model()->findbyPk($id!==null ? $id : $_GET['id']);
if($this->_cv_langue===null)
throw new CHttpException(500,'The requested cv_langue does not exist.');
}
return $this->_cv_langue;
}
qiang
(Qiang Xue)
6
your method is defined in controller, but you are calling it on the model
ouhman
(Ouhman)
7
Ok sorry I understand now.
Thank you Qiang!