Reputation: 1
I have an articles table and an activationpages table and I want to call the activationpages table on my article controller so that my 'if statement' in my articles/view/add would work. it always say "undefined variable I'm a beginner at cakephp so please if someone could just help me.
here's my articles/controller code(I have commented my added codes)
function add() {
if (!empty($this->data)) {
$this->Article->create();
if ($this->Article->save($this->data)) {
$this->Session->setFlash(__('The article has been saved', true));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The article could not be saved. Please, try again.', true));
}
}
$users = $this->Article->User->find('list');
$categories = $this->Article->Category->find('list');
$statuses = $this->Article->Status->find('list');
//$activationpage = $this->set('activationpage');
$this->set(compact('users', 'categories', 'statuses'));
}
and here's my view/add "if statement"
<?php if ($activationpage['Activationpage']['studentstatus_id']==2): ?>
Upvotes: 0
Views: 1147
Reputation: 848
I asume that you have the table activationpages
. When you use the following:
$this->loadModel('Activationpage');
you can communicate with that table. This code creates the model in $this->Activationpage
.
I did not get what you want to do with it next... Maybe you could give a clear explanation?
Upvotes: 1