PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, January 22, 2022

[FIXED] edit more posts on one page

 January 22, 2022     cakephp, php     No comments   

Issue

I want to edit more posts on one edit page. By cookbook there are in every post row 3 actions, edit, view and delete.

But now I need to create 1 edit page with a group of posts and there I want to edit them.

In controller I fetched rows I need (2 rows of posts).

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

then throw foreach I filled data:

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

and in view when debuging

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

with these I get 2 post data arrays: array(1) and array(2)

But I don't know how to edit them in forms. I tried to put (vulgaris) edit rows in foreach but I get 2 same forms(with data from array(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'));
}

I don't know where to put $value from foreach.

These is only an example of form. posts because posts are in cookbook.

And maybe someone knows if I will have a problem when I will need to save edited arrays of data. (use 1 submit on the end of the form or in every row 1)


Solution

resolved with: (need to turn my brain ON)

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


Answered By - marko_b123
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing