Welcome Guest, Not a member yet? Register   Sign In
insert batch with group checkbox
#1

Hi. I have a group of checkbox like this:

Code:
<input type="checkbox" name="preview[]" value="1"/>
<input type="checkbox" name="preview[]" value="1"/>
<input type="checkbox" name="preview[]" value="1"/>

and the follow code in my controller:

PHP Code:
for($i 0$i $count$i++)
      {

        foreach($this->request->getPost('preview') as $preview)
        {
          $c = array('preview' => $preview);

          $data[$i] = array(
            'article_id' => $this->request->getPost('article_id'),
            'name'       => $names[$i],
            'text'       => $this->request->getPost('text')[$i],
            'title'      => $this->request->getPost('title')[$i],
            'alt'        => $this->request->getPost('alt')[$i],
            'preview'    => $c,
          );
        }
      }

      $imagesModel = new ImagesModel();
      $save $imagesModel->insertBatch($data); 

The value of checkbox is wrong. This is or always 1 or always 0. I have tried too the ternary operator, something like this:

PHP Code:
$c $this->request->getPost('preview') == 0

but the problem has not been resolved.

Someone can help me please? Thanks  Smile
Reply


Messages In This Thread
insert batch with group checkbox - by eleumas - 07-02-2020, 02:03 AM
RE: insert batch with group checkbox - by eleumas - 07-02-2020, 07:19 AM
RE: insert batch with group checkbox - by eleumas - 07-02-2020, 12:36 PM



Theme © iAndrew 2016 - Forum software by © MyBB