1

I have a Node Model with variable translateFields (using CakePhp):

class Node extends AppModel {
   public $translateFields = array('title');
   .....
}

For any case (not all), I want change to:

public $translateFields = array('title','field_image');

How I do this? Change in Controller or where?

2
  • Where do you call Node class? Commented Feb 9, 2015 at 13:59
  • 1
    I would either do it in the relevant actions directly, or derive a new class with the extra value if some of the methods have to be modified as well, and then instantiate the right one in said actions. This is just a first idea though; without more details on the situation it is difficult to tell. Commented Feb 9, 2015 at 13:59

2 Answers 2

1

See all Models inherit AppModel ,correct? So define the variable in AppModel. Therefore it will be accessed as will be defined in parent. Also you can override like you used different array indexes.Hope it makes sense.

Sign up to request clarification or add additional context in comments.

Comments

1

In a Controller or another Model which uses the Node model:

$this->Node->translateFields = array('title','field_image');

In a method of Node:

$this->translateFields = array('title','field_image');

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.