0

コントローラーにフォームのドロップダウン値を渡してもいいですか。この後、DB テーブルに値を送信できます。

 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>'
4

1 に答える 1

1

はい、保存できます。上記のフォームに従って、これはビュー内のコントローラーアクションに投稿されます

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());
}

以下は、必要に応じて変更できる sudo コードです。さらに理解するには、cakephp.orgにアクセスしてください。

于 2013-07-26T05:21:30.657 に答える