Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
Subform with nuLookup and read only object from other tables Topic is solved
-
- Posts: 132
- Joined: Sun Dec 16, 2018 6:13 pm
- Location: România
- Has thanked: 30 times
- Been thanked: 4 times
Subform with nuLookup and read only object from other tables
Hello,
I have a subform in which I have to add records using a nulookup object, I want the other readonly text objects to be populated with information that is contained in 2 different tables and that have a key to the initial information from nulookup.
That's all I managed to do This is how I would like it to look
The information that appears in the read only object objects can be found in other tables and should not be modified from this subform. Also, I don't want to save it in the subform table.
Thanks!
I have a subform in which I have to add records using a nulookup object, I want the other readonly text objects to be populated with information that is contained in 2 different tables and that have a key to the initial information from nulookup.
That's all I managed to do This is how I would like it to look
The information that appears in the read only object objects can be found in other tables and should not be modified from this subform. Also, I don't want to save it in the subform table.
Thanks!
You do not have the required permissions to view the files attached to this post.
nuBuilderForte .... BIG Like !!!
-
- nuBuilder Team
- Posts: 4299
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 445 times
- Contact:
Re: Subform with nuLookup and read only object from other tables
I think this could be solved by using Display Objects.
When a lookup value is picked, set the Display values with PHP nuSetFormValue()
Then, depending on your table schema, the display SQL could look like this:
When a lookup value is picked, set the Display values with PHP nuSetFormValue()
Then, depending on your table schema, the display SQL could look like this:
Code: Select all
SELECT something FROM `some_table`
WHERE
some_table_foreign_key = (SELECT subform_table_lookup_id FROM subform_table WHERE subform_table_id = '#RECORD_ID#');
-
- Posts: 132
- Joined: Sun Dec 16, 2018 6:13 pm
- Location: România
- Has thanked: 30 times
- Been thanked: 4 times
Re: Subform with nuLookup and read only object from other tables
Hi, I solved the problem , after an idea from here like this:
1. In my form's Custom Code, I added this code:
2. I created a PHP procedure:
It works OK, but because those objects in the subform (with the role of displaying information only) are not found in the database, when I have to save the form, I get errors in the NuDebug results.
How could I eliminate these errors?
Thanks!
1. In my form's Custom Code, I added this code:
Code: Select all
var sf = 'misi_defect_sf';
function fillObjectInfo(object_nr, misidef_obiectiv, misidef_struct){
$('#' + sf + object_nr + 'misidef_obiectiv').val(misidef_obiectiv).change();
$('#' + sf + object_nr + 'misidef_struct').val(misidef_struct).change();
nuHasNotBeenEdited();
}
function getObjectInfo(){
var nrOfRow = nuSubformObject(sf).rows.length;
for (var i = 0; i <nrOfRow-1; i ++) {
var object_id = $("[id^='" + 'misi_defect_sf' + nuPad3(i) + 'misidef_def' + "']").val() ;
nuSetProperty('object_nr', nuPad3(i));
nuSetProperty('object_id', object_id);
nuRunPHPHidden('getObjectPHP', 1);
}
}
getObjectInfo();
Code: Select all
function getAllObjectsInfo($object_id) {
$sql = "SELECT lucrari_ambarcatiunenr, lucrari_struct FROM lucrari WHERE lucrari.lucrari_id = ?";
$qry = nuRunQuery($sql, [$object_id]);
$row = db_fetch_object($qry);
return array(
"misidef_obiectiv" => $row->lucrari_ambarcatiunenr,
"misidef_struct" => $row->lucrari_struct,
);
}
$empInfo = getAllObjectsInfo('#object_id#');
$misidef_obiectiv = $empInfo["misidef_obiectiv"];
$misidef_struct = $empInfo["misidef_struct"];
$j = "fillObjectInfo('#object_nr#', '$misidef_obiectiv', '$misidef_struct'); ";
nuJavascriptCallback($j);
How could I eliminate these errors?
Thanks!
nuBuilderForte .... BIG Like !!!
-
- nuBuilder Team
- Posts: 4299
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 445 times
- Contact:
Re: Subform with nuLookup and read only object from other tables
What errors do you get? Could you upload a sample database with a minimal example? In that way it's much easier to reproduce.
-
- Posts: 132
- Joined: Sun Dec 16, 2018 6:13 pm
- Location: România
- Has thanked: 30 times
- Been thanked: 4 times
Re: Subform with nuLookup and read only object from other tables
Hi,
These errors are normal, because my table for this subform contains only 3 columns Record ID, foreign key and nulllookup ID, when saving the form I want to save any changes in the form and lookup in the subform, I don't want to save the other objects in the subform in the database table, they will be repopulated upon entering edit mode.
Can I remove these errors so they no longer appear in nuDebug for my subform?
These errors are normal, because my table for this subform contains only 3 columns Record ID, foreign key and nulllookup ID, when saving the form I want to save any changes in the form and lookup in the subform, I don't want to save the other objects in the subform in the database table, they will be repopulated upon entering edit mode.
Can I remove these errors so they no longer appear in nuDebug for my subform?
Code: Select all
[0] :
===USER==========
globeadmin
===PDO MESSAGE===
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE `misidef_id` = '62febe031d61c84'' at line 1
===SQL===========
UPDATE misidef SET WHERE `misidef_id` = '62febe031d61c84';
===BACK TRACE====
C:\wamp64\www\sisf1\core\nudata.php - line 422 (nuRunQuery)
C:\wamp64\www\sisf1\core\nuapi.php - line 85 (nuUpdateDatabase)
nuBuilderForte .... BIG Like !!!
-
- nuBuilder Team
- Posts: 4299
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 445 times
- Contact:
Re: Subform with nuLookup and read only object from other tables
I came across an error in nuSubFormsEdited(), file nudata.php, which occurs when only the subform is edited but not the mainform.
Fix:
I'm not sure if that is also going to fix your error.
Fix:
Code: Select all
function nuSubFormsEdited($nudata) {
$c = count($nudata);
if ($c == 1) return false; // no subforms
for($d = 1 ; $d < $c ; $d++){
$sf = $nudata[$d];
$edited = $sf->edited;
$rows = $sf->rows;
$countRows = count($rows);
for($r = 0 ; $r < $countRows ; $r++){
if(nuEditedRow($edited[$r])){
return true;
}
}
}
return false;
}
-
- Posts: 132
- Joined: Sun Dec 16, 2018 6:13 pm
- Location: România
- Has thanked: 30 times
- Been thanked: 4 times
Re: Subform with nuLookup and read only object from other tables
Sample database :
In form FF2 I have a subform FF3, it contains the data from form FF1. When I save FF2, an error appears because the 2 objects in the subform "OnlyViewObject-Text002 - T1" and "OnlyViewObject-Text003 - T1" are not found in Table3.
How can I eliminate these 2 errors?
I hope what I posted makes sense.In form FF2 I have a subform FF3, it contains the data from form FF1. When I save FF2, an error appears because the 2 objects in the subform "OnlyViewObject-Text002 - T1" and "OnlyViewObject-Text003 - T1" are not found in Table3.
How can I eliminate these 2 errors?
You do not have the required permissions to view the files attached to this post.
nuBuilderForte .... BIG Like !!!
-
- nuBuilder Team
- Posts: 4299
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 445 times
- Contact:
Re: Subform with nuLookup and read only object from other tables
Thanks for the sample. Here's a patched nudata.php. Please try it and let me know the outcome.
You do not have the required permissions to view the files attached to this post.
-
- Posts: 132
- Joined: Sun Dec 16, 2018 6:13 pm
- Location: România
- Has thanked: 30 times
- Been thanked: 4 times
Re: Subform with nuLookup and read only object from other tables
Hi,
with the version you sent of the nudata.php file, the errors for objects that are not found in the database table no longer appear.
If it is possible to include a button in the properties of the object to hide the errors specific to that object.
Hiding all errors could lead to longer debugging of the application in case of unknown errors.
Thanks!
with the version you sent of the nudata.php file, the errors for objects that are not found in the database table no longer appear.
If it is possible to include a button in the properties of the object to hide the errors specific to that object.
Hiding all errors could lead to longer debugging of the application in case of unknown errors.
Thanks!
nuBuilderForte .... BIG Like !!!
-
- nuBuilder Team
- Posts: 4299
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 445 times
- Contact:
Re: Subform with nuLookup and read only object from other tables
Well, the modified code does not hide errors. It simply checks if an object's id exists in a table and does not generate insert/update statements if it doesn't