Prevent input multiple time

Hello @johnny , so i try to input data using GCE from slow internet. I fill the form, and click save 10 x. And it inserts data 10 x. It should be just inserted one times.

So my question is, how to prevent multiple times insert with gce ?

Hello @heruprambadi ,

I never thought about that to be honest. I think I should just disable the button “Insert” when you press the button. I will revisit it for the next version release and let you know.

Regards
Johnny

Yeah, i never thought about that too. But some of my clients still use very slow internet connection, and i just found the same data inserted by my client with just 1 sec time difference. From my experience, it caused by slow internet connection. So when they click save button, insert process is so slow and thats make they think they should click save button again to make it fast. And after that, multiple same data inserted.

Another reason is, they just accidentaly click save button twice. But it’s almost imposibble to click it twice from fast internet @johnny

hello @heruprambadi

i add this script in my default view to prevent that happen
in javascript tag

        window.addEventListener('gcrud.form.add-load', () => {
            setLoadingBtnGc();
        });
        window.addEventListener('gcrud.form.edit-load', ({
            detail
        }) => {
            setLoadingBtnGc();
        });

        function setLoadingBtnGc() {
            $('form[class^="gc-form-"]').submit(function() {
                var form = $(this);
                var button = form.find('button[type="submit"]');
                var labelBefore = button.html();
                button.prop('disabled', true);
                button.html('<span class="fa fa-spinner"></span> Loading...');
                enableButtonGcAgain(button,labelBefore);
                return true;
            });
        }
        function enableButtonGcAgain(button,labelBefore){
            setTimeout(function() {
                button.prop('disabled', false);
                button.html(labelBefore);
            }, 3000); // Adjust the timeout as needed (in milliseconds)
        }

Thank’s @nasrul , but i haven’t tested it yet. To test it, i have to find slow internet connection, and it’s really hard to find slow internet from where i am now :smiley:
I think people in big city never experience this problem, that’s why @johnny never thought about it.

Finnaly… i found slow internet and tested it. It works, i can use it on all my view. Thanks @nasrul

Thanks @nasrul for this. In the meantime, I have fixed this issue for the next version which hopefully will be released soon :slight_smile:

hello @heruprambadi
Glad to hear that @heruprambadi

yes thank you so much @johnny

I am glad to announce you that this is now fixed on the latest version of Grocery CRUD (3.0.16)

If you are using Composer then I have good news for you since now we have moved to our private composer server. In short that means that you no longer need to download any zip file for update :slight_smile:

For more you can check the blog post: Grocery CRUD Private Composer | Grocery CRUD Blog

Regards
Johnny

Woow that’s very good news. Now we don’t have to download and replace every update @johnny :smiley: