Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Open a form with a drop-down menu Topic is solved

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Post Reply
cuadradoja
Posts: 27
Joined: Thu Sep 01, 2022 3:42 am
Has thanked: 1 time

Open a form with a drop-down menu

Unread post 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:
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Open a form with a drop-down menu

Unread post 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.
cuadradoja
Posts: 27
Joined: Thu Sep 01, 2022 3:42 am
Has thanked: 1 time

Re: Open a form with a drop-down menu

Unread post by cuadradoja »

It worked perfectly for me... thank you for your timely help. :thumb:
Post Reply