Hi everyone! I face with certain situation - when using custom callback_insert function then after u just click Save (Not insert and back to list!)
GC shows two links - edit record and back to the list like popup messages, and link "edit record" not working!
Explanation:
In GC when u use custom callback_insert and return inserted id by yourself (or true, no matter, everything except false, what means error while inserting)
present some logic if u use custom insert
//in my version GC 1.4.2 //if not use custom callback insert if($this->callback_insert === null) { ..... some login and after inserting creates inserted ID like $insert_result = $this->basic_model->db_insert($insert_data); if($insert_result !== false) { $insert_primary_key = $insert_result; } else { return false; } } else //here custom callback insert { $callback_return = call_user_func($this->callback_insert, $post_data); if($callback_return === false) { return false; } } //finally check if inserted primary key exist if(isset($insert_primary_key)) return $insert_primary_key; else return true;
How we see above $inserted_id only gets in usual case and in custom callback return TRUE!
So this true casting to 1 and adds to edit link so when u click it there is always edit record with ID = 1 what terrible wrong! Why just not check what user callback return?
Something like this after calling custom function for insert:
$callback_return = call_user_func($this->callback_insert, $post_data); if($callback_return === false) { return false; } //here we sure that this is not true so what this is? sure it can be only ID elseif($callback_return !== true) { $insert_primary_key = $callback_return; }
Maybe this all already resolve in some ways before i write this. Anyway thanks for atention:)