【问题标题】:Cakephp how to display a particular record when searched using one fieldCakephp如何在使用一个字段搜索时显示特定记录
【发布时间】:2014-10-13 10:47:22
【问题描述】:

我是 cakephp 新手。

我有两个相互关联的表(student 和 payment_detail)。 学生有很多付款详情和 付款详情属于学生。

我有一个搜索视图:

<?php echo $this->Form->input('Student.roll_no', array('label' => __('Roll No'))); ?> 
<?php echo $this->Form->end(__('View')); ?> 

在控制器中查看方法:

public function view(){ 
        if ($this->request->is('post')) { 
            $this->request->data; 
            return $this->redirect(array('action' => 'detailedview'));                   
        }
}

当我单击查看按钮时,它会将我重定向到详细视图。所以我的问题是如何为控制器创建详细视图方法来检索与特定 roll_no 相关的记录中的所有字段。

【问题讨论】:

    标签: cakephp cakephp-1.3 cakephp-2.3


    【解决方案1】:

    您需要:

    1) 将视图函数更改为:

    public function view( $id=null ){ 
            if ($this->request->is('post')) { 
                $this->redirect(array('action' => 'detailedview', $id));
            }
    }
    

    2) 在您的控制器中添加以下功能:

    public function detailedview( $id=null ) {
    ....
    }
    

    在您这样做之前,我建议您再次阅读文档并阅读博客教程。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-07
      • 1970-01-01
      • 2013-06-26
      • 1970-01-01
      相关资源
      最近更新 更多