Page 1 of 1

Open a form with a drop-down menu

Posted: Sat May 24, 2025 5:44 pm
by cuadradoja
Hi,

I'm trying to open two forms (Notas and Adjuntos) from a drop-down menu, but when I do, I get a message saying: error loading the form.

I extracted the code from the nuhome form and adapted it as shown below:

Code: Select all

function nuHomeOpenForm(f, r, event) {
    n = event.ctrlKey ? '2': '0';
    nuForm(f, r, '', '', n);
}

function nuHomeOpenMenu(event, menu, element) {
    event.stopPropagation();
    ctxmenu.show(menu, element);
}

function nuHomeOpenCreateMenuConfig(menuType, event) {

    const baseMenus = {
        Accion: [
            { text: nuContextMenuItemText("Guardar", "far fa-save"), action: () => nuSaveAction() },
            { text: nuContextMenuItemText("Nuevo", "far fa-edit"), action: () => nuHomeOpenForm('Notas', '', event) },
            { text: nuContextMenuItemText("Adjuntar", "fas fa-paperclip"), action: () => nuHomeOpenForm('Adjuntos', '', event) }
        ]
    };

    if (menuType === 'Database' && nuSERVERRESPONSE.is_demo) {
        baseMenus.Database = baseMenus.Database.filter(item => item.text !== "Sessions");
    }

    const menu = [{ text: nuTranslate(menuType) }, ...baseMenus[menuType]];
    return menu;
}

function nuHomeMenuClick(element, event, menuType) {
    const menu = nuHomeOpenCreateMenuConfig(menuType, event);
    nuHomeOpenMenu(event, menu, element);
}


Could you help me?... Thank you so much in advance. :roll:

Re: Open a form with a drop-down menu

Posted: Sat May 24, 2025 5:53 pm
by kev1n
Hi,

The nuForm() function expects a form ID (primary key) as its first parameter.

If you're using a newer version of nuBuilder, you can alternatively pass code:form_code instead.
Refer to the wiki examples for more details.

Re: Open a form with a drop-down menu

Posted: Sat May 24, 2025 8:15 pm
by cuadradoja
It worked perfectly for me... thank you for your timely help. :thumb: