close_edit_form

Item.close_edit_form()
domain:

client

language:

javascript

class:

Item()

Description

The close_edit_form method closes the item’s edit form. Before destroying it, it queries up to three handlers in cascade, all sharing the same name (on_edit_form_close_query) but defined on different classes:

  1. Class Item() on_edit_form_close_query

  2. Class Group() on_edit_form_close_query (the item’s parent group)

  3. Class Task() on_edit_form_close_query (the task)

The table below summarizes how close_edit_form behaves depending on which handler is queried and what it returns:

Step

Handler called

Behavior

1

Item.on_edit_form_close_query

If defined and it returns true, the form is destroyed, edit_form is set to undefined, and the method exits.

If defined and it returns false, the operation is aborted and the method exits.

If undefined, or it returns undefined, move to step 2.

2

Group.on_edit_form_close_query (item’s parent group)

Same logic as step 1: true closes the form, false aborts the operation, undefined (or no handler defined) moves to step 3.

3

Task.on_edit_form_close_query

Same logic: true closes the form, false aborts the operation.

If this handler is also undefined (or returns undefined), the form is closed by default.

Summary: close_edit_form walks through the three levels (item → group → task) until it gets a definitive answer (true or false). If none of the levels decides, the form is closed by default.

Typical use case

close_edit_form is mostly used with Virtual tables.

Example

In this example, form 2 has a Next Form button. On click, the form is closed and form 1 is displayed after a short delay.

function on_edit_form_created(item) {
    item.edit_form.find('#ok-btn')
        .text('Next Form')
        .off('click.task')
        .on('click', function() {
            item.close_edit_form();
            setTimeout(function() {
                show_f1(item);
            }, 300);
        });
}

function on_edit_form_close_query(item) {
    return true;
}

See also

Related attributes

Related functions

Related concepts