hi all im trying to load information from a table into a dropdown box. I'm trying to load account_id from my accounts_users table which contains - id, accounts_id, user_id into a dropdown box.
account_id should only show when the id from the users table = user_id from the accounts_users table. at the moment the dropbox is only loading the id from the accounts_users table.
here is my add function
function add() {
$this->set('title_for_layout', 'Please Enter Your Temaplate Details');
$this->set('stylesheet_used', 'style');
$this->set('image_used', 'eBOXLogo.jpg');
$accounts=$this->User->AccountsUser->find('list', array('conditions' => array('user_id' => $this->Auth->user('id'))));
debug($accounts);
if($this->request->is('post')){
$this->Template->create();
if ($this->Template->save($this->request->data)) {
$this->Session->setFlash('The template has been saved');
$this->redirect( array('controller' => 'Fields','action' => 'add'));
} else {
$this->Session->setFlash('The template could not be saved. Please, try again.');
}
}
$this->set('accounts', $accounts);
}
and here is the add view
<?php
echo $this->Form->create('Template', array('action'=>'add'));
echo $this->Form->input('name',array('label'=>'Template Name: '));
echo $this->Form->input('account_id',array('label'=>'Business: ', 'type' => 'select', 'options' => $accounts));
echo $this->Form->input('description',array('label'=>'Short Description Of Template: '));
echo $this->Form->end('Click Here To Submit Template');
?>
the debug outputs
app\Controller\TemplatesController.php (line 20) array( (int) 3 => '3' )
the user in the accounts_users table only has 1 entry with id=3, account_id=10 and user_id=14