0

I have the "admin" controller. In the add($model) function I want to add some data inside the $model.

How can I do something like this:

$this->$model->save($this->request->data);

Is there a better way?

Example:

Add Function

function add($model = null){
    if($model != null){
        $this->$model->save($this->request->data);
    }
}

GET URL http://mysite.com/admin/add/mymodel

tereško
  • 58,060
  • 25
  • 98
  • 150
  • 2
    I’m not sure what you’re asking? If `$model` is `null`, that what model do you actually want to save the data to? – Martin Bean Jul 08 '13 at 15:41
  • 1
    Can you explain what you are trying to achieve, it may be that your problem can be solved with a different solution. Also can you show more of your code than just the one line. The whole `add()` method would be good – fullybaked Jul 08 '13 at 15:43
  • $model = null if no model was passed via get. – Eduardo Arruda Pimentel Jul 08 '13 at 15:43

0 Answers0