【问题标题】:Get parent variable in child controller在子控制器中获取父变量
【发布时间】:2014-01-19 03:02:57
【问题描述】:

我有属于CoursesLessons。我想要一个添加的课程重定向到该课程的课程索引而不是整个课程索引。

我已经在 add() 函数中尝试过这个:

return $this->redirect(array('controller' => 'courses', 'action' => 'view', $this->Lesson->Course->$id));

但是重定向不起作用。我怎样才能让它回到 http://www.example.com/courses/view/2

谢谢!

【问题讨论】:

    标签: php cakephp http-redirect


    【解决方案1】:

    $this->Lesson->Course->$id 不会给你开箱即用的课程 ID。

    我想课程ID已经在请求中,$this->request->data['Lesson']['course_id'];

    【讨论】:

      猜你喜欢
      • 2023-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多