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 关于#linux#的问题(输入输出错误):出现这个界面接着我重新装系统,又让修电脑的师傅帮我扫描硬盘(没有问题)用着用着又卡死(相关搜索:固态硬盘)
  • ¥15 cv::resize不同线程时间不同
  • ¥15 web课程,怎么做啊😭没好好听课 根本不知道怎么下手
  • ¥15 做一个关于单片机的比较难的代码,然后搞一个PPT进行解释
  • ¥15 python提取.csv文件中的链接会经常出现爬取失败
  • ¥15 数据结构中的数组地址问题
  • ¥15 maya的mel里,怎样先选择模型A,然后利用mel脚本自动选择有相同名字的模型B呢。
  • ¥15 Python题,根本不会啊
  • ¥15 会会信号与系统和python的来
  • ¥15 关于#python#的问题