Page 1 of 1

Number input in Modal - Failed to get mandatory argument: table

Posted: 22 January 2021, 19:41
by Crazyboog
Hi,

I'm developing the texasholdem project and I have a weird error with a modal dialog.

I'm using a modal dialog with just a number input and two buttons (OK and Cancel) to allow to player to choose a bet amount. It works fine when using the buttons to confirm or cancel the bet, but when I click into the input area and press enter, it opens a page with the below content.

Untitled.png
Untitled.png (89.27 KiB) Viewed 820 times

Sorry, an unexpected error has occurred...

Failed to get mandatory argument: table

#0 /var/tournoi/release/tournoi-210121-0943-gs/www/include/APP_GameAction.inc.php(32): APP_Action->getArg('table', 1, true)
#1 /var/tournoi/release/tournoi-210121-0943-gs/www/include/APP_GameAction.inc.php(21): APP_GameAction->initGameTableObjects()
#2 /var/tournoi/release/tournoi-210121-0943-gs/www/include/webActionCore.inc.php(182): APP_GameAction->__construct()
#3 /var/tournoi/release/tournoi-210121-0943-gs/www/index.php(247): launchWebAction('texasholdem', 'action_texashol...', '__default', false, false, NULL, true, false)
#4 {main}

It seems it triggers a default action which does not contain the required argument. Any idea why that happenned?

Re: Number input in Modal - Failed to get mandatory argument: table

Posted: 22 January 2021, 21:03
by Tisaac
What does the modal code looks like ?

Re: Number input in Modal - Failed to get mandatory argument: table

Posted: 23 January 2021, 10:20
by Crazyboog
The modal code is shown below.

Code: Select all

// Create the new dialog over the play zone.
                this.raiseDlg = new ebg.popindialog();
                this.raiseDlg.create('chooseRaise');
                this.raiseDlg.setTitle(_("Choose Amount"));
                this.raiseDlg.setMaxWidth(500); // Optional

                var html = this.format_block('jstpl_choose_raise_dialog', {
                    INPUT_LABEL: _("Amount"),
                    RAISE_BUTTON_LABEL: _("OK"),
                    CANCEL_BUTTON_LABEL: _("Cancel")
                });  
                
                // Show the dialog
                this.raiseDlg.setContent(html);
                this.raiseDlg.show();
                

                dojo.connect($('raisebutton'), 'onclick', this, function(evt) {
                    var raiseAmount = $("raiseAmount").value;
                    this.raiseBy(raiseAmount);
                    evt.preventDefault();
                    this.raiseDlg.destroy();
                });

                dojo.connect($('cancelbutton'), 'onclick', this, function(evt) {
                    evt.preventDefault();
                    this.raiseDlg.destroy();
                });
and the

Code: Select all

jstpl_choose_raise_dialog
template is defined as follows:

Code: Select all

var jstpl_choose_raise_dialog = ' \
    <form> \
        <label for = "raiseAmount">${INPUT_LABEL}</label> \
        <input type = "number" id = "raiseAmount" value = 0><br> \
    </form> \
    <a type="button" class = "action-button bgabutton bgabutton_blue" id = "raisebutton">${RAISE_BUTTON_LABEL}</a> \
    <a type="button" class = "action-button bgabutton bgabutton_blue" id = "cancelbutton">${CANCEL_BUTTON_LABEL}</a> \
';

Re: Number input in Modal - Failed to get mandatory argument: table

Posted: 24 January 2021, 13:09
by Tisaac
Just remove the form or connect the onsubmit event.

Re: Number input in Modal - Failed to get mandatory argument: table

Posted: 24 January 2021, 18:27
by Crazyboog
Thanks for the tip, that did the trick. I don't understand why with the form it causing this error though.