⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Clone a Row / Copy a Row use add_action



ypazval
  • profile picture
  • Member

Posted 07 September 2016 - 22:08 PM

Hello Goodnight.

 

I've been trying to create a function with the add_action that allows me to clone a complete row can then edit , or allow me to add a new record using add form function but copying the data from selected record.

 

I was trying to clone the record, with this:

 

$crud->add_action('Clonar', '/images/clonar.png', array($this,'editar_instrumento_cop_aut_esc_pub'));

 

...

 

function clonar_instrumento_cop_aut_esc_pub($primary_key, $row)
    {
      $limit = 10;
      $offset = 0;
           
        $query = $this->db->get_where('cop_aut_esc_pub', array('id_doc' => $primary_key), $limit, $offset);
                
        if ($query->num_rows() > 0)
{
$res = $query->result();
$row = $res[0];
}

$doc_insert = array(
            
            "num_cop" => $row->num_cop,
            "fec_exp" => $row->fec_exp,
            "num_esc" => $row->num_esc,
            "fec_otor" => $row->fec_otor,
            "act_neg" => $row->act_neg,
            "nom_conv" => $row->nom_conv,
            "val_pre" => $row->val_pre,
            "num_folio" => $row->num_folio,
             "num_ced" => $row->num_ced,
            "id_usu" => $_SESSION['id_usu'],
             "num_pin" => ""
        );

 $this->db->insert('cop_aut_esc_pub', $doc_insert);
            
    }

 

....but when you refresh the page cloned the first a lot of times and have to cancel, without having given the clone button .

 

 

Someone has done and could guide me ? Thank you very much.

 

 

 


ypazval
  • profile picture
  • Member

Posted 20 September 2016 - 18:41 PM

Some ideas to do this? :(