We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Help get from view Update multiple row

<form method="post" name="form1">

<input name="check[1]" type="checkbox" value="1"/> <input name="quantity[1]" type="checkbox" value="5"/>

<input name="check[2]" type="checkbox" value="2"/> <input name="quantity[2]" type="checkbox" value="2"/>

<input name="check[3]" type="checkbox" value="3"/> <input name="quantity[3]" type="checkbox" value="8"/>

<input type="submit" name="listupdate" class="btn btn-success" value="Update"> </form>

in controllers

foreach ($_POST['check'] as $value) 

{

code get post update....

}

Help me ! Thanks



3.4k

Post your solution then, you know, to help others and to prevent another 979 case later.

Done



3.0k

Ok, This is my solution

                foreach ($this->request->getPost('check') as $value) 
                  {
                        if(is_numeric($this->request->getPost()['quantity'][$value]))
                        {
                              $valueupdate = $this->request->getPost()['quantity'][$value];
                              $updatelist = Mytable::findFirstById($value);
                              if($updatelist)
                              {
                                  $updatelist->assign(['quantity' => $valueupdate]);
                                  if($updatelist->save())
                                  {
                                    // Complete
                                    return $this->response->redirect('/'); 
                                  } 
                              }
                        }      
                  }

It was working