I have two tables, and a set_relation_n_n beetween them:
Museum: id, name, ...
Category: id, name, ...
Museum_x_Category: museum_id, category_id
The relation is defined by this line:
$crud->set_relation_n_n('CategorÃas', 'Museum_x_Category', 'Category', 'museum_id', 'category_id', 'name', 'category_id' );
I was getting these "An error ocurred on insert" and "An error has occurred on saving." errors when adding or editing.
The cause was: the non-utf8 character in the word 'CategorÃas'. Replacing this word by 'Categorias' (note the Ã), it works.
Also, i had to remove the last parameter 'category_id', because it was assigning me all the museums to the first category (id=1). Gotta do some research to understand this behavior of GroceryCRUD. Probably it is correct.
So now, it works.
Hope my solutions save time to anybody else.