Hi
I'm trying to create a subform which sends some data to the database.
each row should contain a hidden field which contains the nuhash USER_TEAM Value.
How am I able to set the Input field hidden so that the rows contain automatically the value?
I thoud there is a input field class "hash_variable". (just a succesition)
If I'm on the wrong way, - how do I send hash_coockie values combined with the other fields to the database ?
Kind regards,
Michael
Welcome to the nuBuilder Forums!
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
Beginners question: How to define a default value to a hidden textvalue?
-
- Posts: 5
- Joined: Wed Jun 26, 2024 10:40 pm
-
- nuBuilder Team
- Posts: 4581
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 76 times
- Been thanked: 536 times
- Contact:
Re: Beginners question: How to define a default value to a hidden textvalue?
Hi Michael,
To populate a specific field in the subform with the user's team, use the JavaScript function
Let me know if you need an example.
To populate a specific field in the subform with the user's team, use the JavaScript function
nuUserTeam()
in combination with the nuSetValue() function.Let me know if you need an example.
-
- Posts: 5
- Joined: Wed Jun 26, 2024 10:40 pm
Re: Beginners question: How to define a default value to a hidden textvalue?
Yes, that way I tryed it and it works in a normal form, but how can I use it in subform?
There I only found the way of custom code of this field (onclick, or so) bit it didn't work until now.
I tried a Input field (Text) and custom code: nuSetValue('tra_mandant', nuUserTeam());
But then nothing happens.
There I only found the way of custom code of this field (onclick, or so) bit it didn't work until now.
I tried a Input field (Text) and custom code: nuSetValue('tra_mandant', nuUserTeam());
But then nothing happens.
-
- nuBuilder Team
- Posts: 4581
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 76 times
- Been thanked: 536 times
- Contact:
Re: Beginners question: How to define a default value to a hidden textvalue?
Every subform field is composed of three parts:
1. Subform Object ID – e.g.,
2. Row number – a three-digit, zero-padded index (e.g.,
3. Object (field) Id – e.g.,
Combined, a full field ID might look like:
To populate a field in the current subform row, add an afterinsertrow event to the subform and call within it.
Declare this function in the form's Custom Code field
1. Subform Object ID – e.g.,
mysubformId
2. Row number – a three-digit, zero-padded index (e.g.,
000
) 3. Object (field) Id – e.g.,
tra_mandant
Combined, a full field ID might look like:
mysubformId000tra_mandant
To populate a field in the current subform row, add an afterinsertrow event to the subform and call
Code: Select all
subformAddUserTeam(event)
Declare this function in the form's Custom Code field
Code: Select all
function subformAddUserTeam(event){
// retrieve the subform Object ID
const sfId = event.currentTarget.getAttribute('data-nu-prefix').slice(0, -3);
// ID of the object whose value needs to be set (change this if targeting a different field))
const objectId = "tra_mandant";
// Value to assign (current user's team)
const value = nuUserTeam();
// Get the current subform row index
rowIndex = nuCurrentRow();
// Construct the full object ID for the target field
const objId = `${sfId}${nuPad3(rowIndex)}${objectId}`;
// Set the field value
nuSetValue(objId, value);
}