⚠ In case you've missed it we are migrating 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 forum is read-only and soon will be archived. ⚠


Member Since 10 May 2020
Offline Last Active Jun 25 2020 10:06 PM

Posts I've Made

In Topic: Error Messages

18 June 2020 - 12:10 AM

Thank you Json!!! this hack works great!


Some notes:

1 (first block): You may want to include the lines also inside the branch for callback_after_update if you need to support custom error messages in those kind of callbacks. Modify also db_insert (for insert/clone operations) and db_delete functions if you want to have the same custom message behaviour on their respective callbacks.

1 (second block): There is a trailing ',' behind $error_message and that mess the json decoding. It should be like this:

echo json_encode(array(
 'success' => $update_result['status'] ,
 'error_message' => $error_message

2-> Find correspondent js inside the theme used for displaying the form, i.e. assets/grocery_crud/themes/flexigrid/js/flexigrid-edit.js. Also you may want to do the same in -add.js file:


else if (!data.success & data.error_message != null)
    alert( message_insert_error );

In Topic: foreign key, does not delete

19 May 2020 - 06:22 PM

Some years has passed since this thread was alive, but that behaviour remains: no message is showed nor action happens when a delete (or an update) try to violate a row referenced from other table with an foreign key ON DELETE/ON UPDATE RESTRICT.


So, for the record, the only solution I found is to set the error message in the CRUD function, i.e.:

$crud->set_lang_string('delete_error_message', "My generic delete error message"); 

And make a callback that checks this situation returning if the delete can go ahead:


The callback function would be something similar to this:

 function check_fk_table($primary_key) {
        //search for elements in the reference table that are using this value
        $this->db->where('id_reference_table', $primary_key);
        $result = $this->db->get('reference_table');
        if ($num_rows != 0) {
            // Violation of FK ON DELETE RESTRICT
            return false;
        } else {
            // No references, no problem: delete
            return true;

In Topic: [updated 24/11/2012] Dependent dropdown (library)

10 May 2020 - 08:27 PM

Hi all!


First of all I want to pay respects to victor and of course to  web-johnny, I really appreciate your work and generosity open sourcing & sharing it.


I want to report that this library works perfectly on GC v1.6.3 too (as of May 2020), and also share two tips to ease its use:


1) In my case I had to add index.php, to the url parameter, as Victor already had answered in some other post in this same thread. 

 "url" => base_url() .'index.php/'. __CLASS__ . '/' . __FUNCTION__ . '/',

2) I think the next question is answered as follows, as I have two different dependent dropdowns on the same CRUD (linked to the same father dropdown, but for sure it is the same solution if they are cascaded dropdowns).


Hi Victor,


I have same problem like everyone, the first dropdown can be used, when i select one option the first dropdown the second dropdown still disabled. I am using GC 1.6 and your library version 1.5.

Please help me. Thanks.


For two (or more) dependent dropdowns segment_name parameter is mandatory, so you have to give it a different name for each dropdown (it is the last parameter so pay attention to add an ending ',' on previous line):

'segment_name' =>'second_select' 

Best regards,