doutongwei4380 2013-07-26 05:14
浏览 27
已采纳

将表单下拉值传递给控制器​​CakePHP

can i pass form dropdown value in my controller and after this, i can send the value in my DB table....please help me i m new in cakephp here is my 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>'
  • 写回答

1条回答 默认 最新

  • dougu7546 2013-07-26 05:21
    关注

    yes you can save it. As per above form this will post to you controller action in view

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

    below is just sudo code you can change as per you need and for more understanding you can visit cakephp.org

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵