This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

pwtan14262
pwtan14262

Hi,

I would like know how can i call a public function from controller in model? In controller testmanager.php, i have created a function onDoingSomething(). Is it possible for me to call this function in model test.php? Example:

In testmanager.php

      public function onDoingSomething(){
     // do something;
     }

In test.php

      use pwtan/test/controllers/testmanager;
       public function onDoingSomething(){
                         //Do something;
                        //Do other things;
    }

Sorry i quite a noob in this. Thanks in advance.

Last updated

Crazymodder
Crazymodder

Hi,

In my eyes thats totally wrong way of doing. Models do not call controller functions. A controller may call a function in a model. What exactly you are trying to do. Maybe we can find another way:)

pwtan14262
pwtan14262

Hi Crazymodder,

Thanks for your replay. In my plugin, i have use relationcontroller which show list of things for user to select. Beside just showing the list, i want to perform addtional things. So i have trace the function in relationcontroller to Modules/Backend/Behaviors/RelationController where there is the following function

public function onRelationButtonAdd()
{
    $this->eventTarget = 'button-add';
    return $this->onRelationManageForm();
}

But i do not want to add my code in here. I would like access this function in my plugin and add my additional code. How can i do that. I hope you understand what i'm try to do. Thanks :)

Crazymodder
Crazymodder

So you want to create your own RelationController? You can do this with normal OO behavoir. Simply create custom class extend it with RelationController and redfine the methods you like. please notice parameters must be the same.

pwtan14262
pwtan14262

Thanks Crazymoder for this suggestion. Will give it go. Thanks again

1-5 of 5

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.