⚠ 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

Set a string to a field value in view



navajo
  • profile picture
  • Member

Posted 28 February 2019 - 17:02 PM

How would I set st1 to a field value in the below code?

 

 

    elseif ($state == 'read')
            {       
           
            /$user_log_record = array(
            "idnumber" => $_SESSION['idnumber'],
            "action_done" => 'Read Tag Event',
            "visited" => $st1,
            "record_dt" => date('Y-m-d H:i')
        );               
             $this->db->insert('tags_read',$user_log_record);
            }   
   
            elseif ($state == 'edit')
   


navajo
  • profile picture
  • Member

Posted 01 March 2019 - 14:19 PM

Found the solution, For anyone interested here is what I Did.

 

I created a callback:

 

$crud->callback_field('tag_no',array($this, 'record_tag_read'));

 

and the function:

 

    function record_tag_read($value = '', $primary_key = null)
    {
       
        $user_log_record = array(
        "idnumber" => $_SESSION['idnumber'],
        "action_done" => 'Read Tag Event',
        "visited" => $value ,
        "record_dt" => date('Y-m-d H:i')
        );               
         $this->db->insert('tags_read',$user_log_record);
         return $value;
   
    }   

 

I also modified the Grocery Crud Library as defined here

 

/topic/2525-callback-addedit-field-changes-the-display-on-the-read-method/