0
안녕하세요, 모두 테이블에서 드롭 다운 상자로 정보를로드하려고합니다. Idle, accounts_id, user_id가있는 accounts_users 테이블에서 account_id를 드롭 다운 상자에로드하려고합니다.cakePHP 테이블의 데이터를 드롭 다운 상자에로드
account_id는 accounts_users 테이블의 사용자 테이블 id = user_id에서만 표시되어야합니다. 현재 dropbox는 accounts_users 테이블에서 ID 만로드하고 있습니다. 여기
내 추가 기능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);
}
이며, 여기에 추가보기
<?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');
?>
디버그 출력
응용 프로그램 \ 컨트롤러 \ TemplatesController.php (라인 20) 배열 ( (int) 3 => '3' )
accounts_users 테이블의 사용자는 ID 1 개 항목이 = 3 ACCOUNT_ID = 10, 14 = USER_ID