在一页上编辑更多帖子

edit more posts on one page

我想在一个编辑页面上编辑更多 post。根据食谱,每 post 行有 3 个操作,编辑、查看和删除。

但现在我需要用一组 post 创建一个编辑页面,我想在那里编辑它们。

在控制器中我获取了我需要的行(2 行 posts)。

$posts= $this->Post->find('list', array('conditions' => array('task_id' => $taskId)));

然后抛出foreach 我填充的数据:

$this->request->data[$i]

并在调试时查看

foreach ($this->request->data as $key => $value) {debug($value);}

有了这些,我得到了 2 个 post 数据数组:array(1) 和 array(2)

但我不知道如何在表单中编辑它们。我试图在 foreach 中放置(普通)编辑行,但我得到 2 个相同的表格(数据来自数组(1))

foreach ($this->request->data as $key => $value) {

    echo $this->Form->create('Post');
    echo $this->Form->input('id');
    echo $this->Form->input('task_id');
    echo $this->Form->input('note');
    echo $this->Form->input('priority');
    echo $this->Form->input('results_link');
    echo $this->Form->end(__('Submit'));
}

我不知道将 foreach 的 $value 放在哪里。

这些只是形式的一个例子。 posts 因为 posts 在食谱中。

也许有人知道我在需要保存已编辑的数据数组时是否会遇到问题。 (在表格末尾或每行 1 中使用 1 个提交)

解决方法:(需要打开我的大脑)

foreach($this->request->data as $key => $this->request->data){}