Welcome to the nuBuilder Forums!

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

Retrieve Checkbox state from Hash Cookie

Questions related to using nuBuilder Forte.
Locked
kev1n
nuBuilder Team
Posts: 4307
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 448 times
Contact:

Retrieve Checkbox state from Hash Cookie

Unread post by kev1n »

Hi,

Calling

Code: Select all

nuDebug(nuHash()); 
in BS, AS etc.

always shows empty values for Checkboxes, even if their state is checked.

One would expect true, false values instead.

Code: Select all

[0] : Array
( 
...
    [exp_table_data] => 
    [exp_run_objects] => 
    [exp_change_pk] => 
    [exp_skip_comments] => 
...
)
Last edited by kev1n on Tue Aug 18, 2020 4:40 am, edited 1 time in total.
kev1n
nuBuilder Team
Posts: 4307
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 448 times
Contact:

Re: Retrieve Checkbox state from Hash Cookie

Unread post by kev1n »

My workaround is to set new Hash Cookies with 0/1 values for each checkbox in nuBeforeSave()

Code: Select all

    $('input[type=checkbox]').each(function () {
          nuSetProperty(this.id + '_checked', this.checked ? '1' : '0');     
});
admin
Site Admin
Posts: 2815
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Retrieve Checkbox state from Hash Cookie

Unread post by admin »

kev1n,

It seems to work for me.
aaa.png

Steven
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4307
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 448 times
Contact:

Re: Retrieve Checkbox state from Hash Cookie

Unread post by kev1n »

Hi Steven,

I'm afraid I wasn't specific enough. The checked status can only not be retrieved when a Procedure is called (but it works fine with BS, AS etc. as you wrote)

A form contains a Checkbox with Object ID: "exp_skip_comments"

In the form's custom code, run

Code: Select all

nuRunPHPHidden('my_procedure', 0);
In the Procedure, output the variable:
nuDebug("#exp_skip_comments#");
Result:

Code: Select all

[0] : 
or with

Code: Select all

nuDebug(nuHash());
Result:

Code: Select all

[exp_skip_comments] => 
admin
Site Admin
Posts: 2815
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Retrieve Checkbox state from Hash Cookie

Unread post by admin »

kev1n,

I believe that is now fixed on Github.


Please test it.


Steven
kev1n
nuBuilder Team
Posts: 4307
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 448 times
Contact:

Re: Retrieve Checkbox state from Hash Cookie

Unread post by kev1n »

Perfect - thanks!
admin
Site Admin
Posts: 2815
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Retrieve Checkbox state from Hash Cookie

Unread post by admin »

.
Locked