Save/update form input on change group

eurtnl

New Member
I have a form whit 10+ groups, is it possible to save/update record when user advance to the next group?
 
You can enable "Save part-edit records" in form/Form processing.
See tooltip "When changing pages on a multi-page or multi-tab form, save the data entered so far in a temporary table and restore it next time the user returns to the same form / record."
 
I was aware of that feature, but i need the data for a game in progress so i can make a standing during the game.
 
Well that helped alot thanks!
I added the js code to an element (on change / blur), had to add the apply-button to the form first.

So when a score is entered and i click the next button it updates the record, but the form reloads and goes back to the first group (beginning of the form). How can I can i get the form to advance to the next group instead of the beginning?
 
I'm still trying to solve this.
What I did is create a file form_11.js and saved it in components/com_fabrik/js
The content of the file is:
JavaScript:
Fabrik.addEvent('fabrik.form.page.change', function(form, dir) {
var form = Fabrik.getBlock('form_11');
form.doSubmit(new Event.Mock(form._getButton('apply')), form._getButton('apply'));
});

But I get an error: Can't find variable: Fabrik
Anybody got a hint?
 
JavaScript:
requirejs(['fab/fabrik'], function() {
Fabrik.addEvent('fabrik.form.page.change', function(form, dir) {
var form = Fabrik.getBlock('form_11');
form.doSubmit(new Event.Mock(form._getButton('apply')), form._getButton('apply'));
});
})
 
Thanks! I got rid of the error.
But the code didn't solve my problem, it even got worse :(

What I'm trying to achieve is to save/update the record when the user changes from form group (prev/next). The save part is working but after that the form returns to the beginning of the form and not to the next/prev group.
Second it would be nice to suppress the notification and only show when the user hits the submit button.

Can this be done?
 
Here's a code I'm using in tabbed templates to return to the same tab after "Apply" is pressed:
Code:
  document.getElement('button[name=apply]').addEvent('click', function () {
        var active_tab = document.getElements('.nav-tabs > li.active a')[0].id;
        Cookie.write('active_tab_' + Fabrik.getBlock('form').id, active_tab, {duration: 0.1});
    });

    });

    window.addEvent('fabrik.loaded', function() {
    //replace 118 with your form id
    var active_tab = Cookie.read('active_tab_118');
    if (active_tab) {
        jQuery('#'+active_tab).trigger("click");
    }

Maybe you can adapt this to your need. In multipage-forms, the groups that are not shown, just have "display:none" attribute. So with some jQuery you could probably find out which form child with a class "page" has not "display:none" style applied, loop throught the elements and apply "display:none" again on the pages that were not shown before your "Apply" code was run.
 
Thanks for your reply.
But with my js knowledge this is out of my league.

However I'm using "Save part-edited records", maybe I can extract the data from the temp-table.
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top