2013-07-26 37 views
0

我可以在控制器通過形式下拉值,在此之後,我可以在我的數據庫表發送值....請幫助我即時通訊CakePHP中新在這裏我job_content.ctp如何在我的控制器中傳遞表單下拉值?

echo'<div class="AcceptButtonFormData">'; 
    echo $this->Form->create('Job' ,array('action' => 'view')); 

    $ipr_value=array('0'=>0.0,'1'=>.1,'2'=>.2,'3'=>.3); 

    echo $this->Form->input('IPR_teeth_pair12',array('type' => 'select','name'=>'drop12', 'options' => $ipr_value,'default'=>0)); 

    echo $this->Form->input('IPR_teeth_pair23',array('type' => 'select','name'=>'drop23', 'options' => $ipr_value,'default'=>0)); 

    echo $this->Form->input('IPR_teeth_pair34',array('type' => 'select','name'=>'drop34', 'options' => $ipr_value,'default'=>0)); 

    echo $this->Form->end(); 
    echo '</div>' 

回答

0

是你可以保存它。按照上述形式,這將張貼到您控制器動作視圖下方

public function view() { 
    // Has any form data been POSTed? 
    if ($this->request->is('post')) { 
     // If the form data can be validated and saved... 
     if ($this->Job->save($this->request->data)) { 
      // Set a session flash message and redirect. 
      $this->Session->setFlash('JobSaved!'); 
      $this->redirect('/jobs'); 
     } 
    } 

    // If no form data, find the recipe to be edited 
    // and hand it to the view. 
    $this->set('jobs', $this->Job->findAll()); 
} 

只是須藤代碼,你可以按需要改變,更多的瞭解,您可以訪問cakephp.org

+0

感謝答覆.... 。如果我選​​擇下拉的值,並提交按鈕下拉列表不能保存在數據庫中,並且如果我檢查窗體下拉值顯示0,意味着如果我選擇我仍然選擇的值.... – deadman

+0

$ ipr_value = array( '0'=> '0.0', '1'=>, '2'=>, '3'=>」 3' 。) '1' 。' 2' ;這樣使用可以解決你的問題並在控制器中打印請求數據 – liyakat

相關問題