⚠ 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

message_insert_error doesn't display when there's a db error



hipo_loco
  • profile picture
  • Member

Posted 03 November 2013 - 00:01 AM

Hello for everybody =) First sorry if my english isn't good (I don't speak english).

 

I'm trying to develop an application in PHP using CI (2.1.4) + Grocery Crud (1.4.1). While I was testing one of the forms, I've tried to insert a duplicate value in my DB (duplicate PK). Nothing happened on DB, but the insert message error didn't display. I obtain the same result if I try to violate other constraints (uniques, FK, etc).

 

I detected where is the problem, but I don't know how to fix it. On flexgrid-add.js, I insert a lot of js alerts to detect where the function breaks. On a particular line, the function exits and doesn't reach the line where the message error is displayed:

$(function(){
    $('.ptogtitle').click(function(){
        if($(this).hasClass('vsble'))
        {
            $(this).removeClass('vsble');
            $('#main-table-box #crudForm').slideDown("slow");
        }
        else
        {
            $(this).addClass('vsble');
            $('#main-table-box #crudForm').slideUp("slow");
        }
    });
        
    var save_and_close = false;

    $('#save-and-go-back-button').click(function(){
        save_and_close = true;

        $('#crudForm').trigger('submit');
    });

    $('#crudForm').submit(function(){
        var my_crud_form = $(this);

        $(this).ajaxSubmit({
            url: validation_url,
            dataType: 'json',
            cache: 'false',
            beforeSend: function(){
                $("#FormLoading").show();
                },
                success: function(data){
                    $("#FormLoading").hide();
                    if(data.success)
                    {
                        $('#crudForm').ajaxSubmit({
                            dataType: 'text',
                            cache: 'false',
                            beforeSend: function(){
                                $("#FormLoading").show();
                            },
                            success: function(result){
                                $("#FormLoading").fadeOut("slow");
                                alert("Before parseJSON"); //It works fine
                                data = $.parseJSON(result); //Makes the function exit
                                alert("After parseJSON"); //Never gets here
                                if(data.success)
                                {
                                    ...
                                }
                                else
                                {
                                    alert( message_insert_error ); //Never gets here
                                }

This error happens on Chrome (30.0.1599.101), Firefox (24.0) and IE (10.0.9200.16721). I didn't test this on Opera or Safari. Thanks in advance for any help. Regards.


edramirez
  • profile picture
  • Member

Posted 11 November 2013 - 17:21 PM

First of all, thanks for the reporting of the problem.

 

But second, don't let that problem stop you from using grocerycrud.

 

When I develop applications, I use set_relation for to ensure that the foreign key constraints are met.

 

When the users ask me why the add or edit operation doesn't proceed, I tell them that they entered an invalid value instead of selecting the correct value from the dropdown :angry: . I also tell them also that they might be re-encoding data that has been encoded before :o . Then I continue to use grocerycrud. I'm not going to wait until Johnny fixes all of the bugs before I start using the software.  B)

 

User: Sir, when I tried to save the data I entered, the program stopped and did not proceed.  :(

Me: Well, that's what you get for entering wrong data or retyping the same data.  <_<

User:Ok I'll fix it.  :wacko:

 

Just wanted to emphasize that software products will always have bugs, but they aren't going to stop us, right?  :D

 

Regards,

 

Ed