我是新来的CakePHP。
我有两个表互相关联(学生和payment_detail)。学生的hasMany paymentDetails和paymentDetails belongsTo关系的学生。
我有一个搜索视图:
<?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'));
}
}
当我点击视图按钮,它重定向我detailedview。所以在这里我的问题是如何创建控制器来检索与特定roll_no记录的所有字段detailedview方法。
您需要:
1)更改您的视图函数:
public function view( $id=null ){
if ($this->request->is('post')) {
$this->redirect(array('action' => 'detailedview', $id));
}
}
2)在你的控制器中添加以下功能:
public function detailedview( $id=null ) {
....
}
在你做,我再次建议阅读文档,做博客教程。