Welcome to the nuBuilder Forums!

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

hash cookies are not populated on form opening

Questions related to using nuBuilder Forte.
Hoxen
Posts: 7
Joined: Thu Sep 10, 2020 9:58 am

hash cookies are not populated on form opening

Unread post by Hoxen »

Hi, I've a problem with building a form that make large use of hash cookies:

The entire form should be dinamically populated on the content of the #form_description# hash cookie.
And everything works just fine if I refresh the page one time after opening it.
But that's also the problem: why the hash cookie that contains the form description is populated only after one refresh?

There is a way the form can use the #form_description# at the first opening?
I see that on the video this problem has been also encoutered for Lookups and solved using nuSetFormValue() to update the values realtime.

Many thanks in advance for any reply.
Hoxen
Posts: 7
Joined: Thu Sep 10, 2020 9:58 am

Re: hash cookies are not populated on form opening

Unread post by Hoxen »

I can further specify that I'm trying to obtain the #form_description# populated on the form first load on an EDIT form.
Don't hesitate to ask me for any information that may be useful to reach a solution, because I really need that the form content change completely based on a parameter that should not be changed.

I will basically create a copy of the form many times, changing only the form_description in order to change all the content.
Any alternative idea to obtain the same result is welcome.
Janusz
nuBuilder Team
Posts: 506
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 8 times
Been thanked: 18 times

Re: hash cookies are not populated on form opening

Unread post by Janusz »

try to place the following code in the: PHP Before Edit; PHP After Save

Code: Select all

$s=nuHash();
nuDebug($s);
in my case it works properly - by checking nuDebug (ctrl+shift+d)
and I do not need to perform refresh.
Is it for all objects, for specific objects, how to replicate your case?

FYI: I had some issue with some need for refresh but it was for the browse form:
https://forums.nubuilder.cloud/viewtopic. ... usz#p19321
If you like nuBuilder, please leave a review on SourceForge
kev1n
nuBuilder Team
Posts: 4307
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 448 times
Contact:

Re: hash cookies are not populated on form opening

Unread post by kev1n »

Where and how do you set the Hash Cookie?
Hoxen
Posts: 7
Joined: Thu Sep 10, 2020 9:58 am

Re: hash cookies are not populated on form opening

Unread post by Hoxen »

Janusz wrote:try to place the following code in the: PHP Before Edit; PHP After Save

Code: Select all

$s=nuHash();
nuDebug($s);
in my case it works properly - by checking nuDebug (ctrl+shift+d)
and I do not need to perform refresh.
Is it for all objects, for specific objects, how to replicate your case?
Thank you, but your solution don't work.
I tried also to change the form into a "Browse and Edit" one. No luck.

I'll try to better explain my situation:
hash_cookie.jpg
What you see here is now a BROWSE and EDIT form.
All the objects correspond to many SQL queries, and all of them uses the same hash cookie, only one, and that's exactly the #form_description#.
The page is supposed to dinamically update themself only changing the form_description of the form.
This allows me to create more clone pages with different contents.
The image show you the page as it appears at the first load.

Checking nuDebug(), the cookies are populated not at the first launch of the form, but after a refresh, everything's just fine and all the objects are correctly populated with the needed data.
kev1n wrote:Where and how do you set the Hash Cookie?
check out the image, all the fields use it, but only the RUN object is effectively using it at the first load. I don't understand why.
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: hash cookies are not populated on form opening

Unread post by kev1n »

Let me rephrase the question:

Where/when is the hash cookie set?
In another form/by clicking a button?
Can you describe which actions are performed before the form is opened?
Hoxen
Posts: 7
Joined: Thu Sep 10, 2020 9:58 am

Re: hash cookies are not populated on form opening

Unread post by Hoxen »

kev1n wrote:Where/when is the hash cookie set?
Uhm, maybe this is the problem. The hash cookies needs to be set?
I supposed that all the form fields, and especially the FORM_DESCRIPTION, that has been declared at the form creation, were loaded and populated automatically at the form opening.
Clearly, after your question... is not what happens.
Yet why the browse table subform is working?
kev1n wrote:Can you describe which actions are performed before the form is opened?
nothing. From the home, the form is loaded. Nothing more.
And after a refresh form, everything works as intended.
kev1n
nuBuilder Team
Posts: 4307
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 448 times
Contact:

Re: hash cookies are not populated on form opening

Unread post by kev1n »

obj.png
Is Team #form_description# a HTML object?
And Assistant + Numero di telefono Display objects?
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: hash cookies are not populated on form opening

Unread post by kev1n »

This is a workaround, to refresh the Select Objects with some Javascript when the form opens:

Add this code to your form’s Custom Code field. Also replace the Object Ids assistant,numero_di_telefono, team with yours.

Code: Select all

if (nuFormType() == 'edit') {
        refreshSelectObject('assistant');
        refreshSelectObject('numero_di_telefono');

	$('#team').html($('#team').html().replace('#form_description#', nuCurrentProperties().form_description));
}
The function refreshSelectObject() is documented here:
https://github.com/smalos/nuBuilder4-Co ... /README.md
Hoxen
Posts: 7
Joined: Thu Sep 10, 2020 9:58 am

Re: hash cookies are not populated on form opening

Unread post by Hoxen »

kev1n wrote:Is Team #form_description# a HTML object?
Yes
kev1n wrote:And Assistant + Numero di telefono Display objects?
Yes

Code: Select all

if (nuFormType() == 'edit') {
        refreshSelectObject('team_assistant_0');
        refreshSelectObject('team_assistant_0_tel');

	$('#team').html($('#team').html().replace('#form_description#', nuCurrentProperties().form_description));
}
"Team" text inside the HTML object is plain text to show only, no replacement to be done.
Replacing only assistant and numero_di_telefono with my correspondant field IDs team_assistant_0 and team_assistant_0_tel but the code don't work.
I tried also changing the nuFormType() from edit to browse, nothing changed.
You can see here a list of the objects and their ID in this screenshot:
Cattura.JPG
Thank you for your help so far, anyway. ;)
If you know any other workaround or a fix for this one, will be really welcome.
You do not have the required permissions to view the files attached to this post.
Post Reply