I also see lookup and select fields.
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.
Button to clone records in the subform
-
- nuBuilder Team
- Posts: 4292
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 444 times
- Contact:
-
- Posts: 58
- Joined: Mon Sep 09, 2019 8:20 am
Re: Button to clone records in the subform
I understood you meant only the fields that weren't being cloned. Excuse me
yes the lookup fields don't have fields connected to the db I use them with php functions to fill in the Brand and Model Size fields. Even the field the select MM field is not connected to the db but has defined values while the position field is connected with a foreign key to another table.
all these fields, however, a few days ago with the clone button were filled in regularly. only the measurement field and the model field were not filled in, or rather they were filled in and then immediately emptied. and cloning an unsaved record copied themselves completely. now no longer
yes the lookup fields don't have fields connected to the db I use them with php functions to fill in the Brand and Model Size fields. Even the field the select MM field is not connected to the db but has defined values while the position field is connected with a foreign key to another table.
all these fields, however, a few days ago with the clone button were filled in regularly. only the measurement field and the model field were not filled in, or rather they were filled in and then immediately emptied. and cloning an unsaved record copied themselves completely. now no longer
Re: Button to clone records in the subform
calida82,
Can you show us the code that runs after each of the Lookups?
Steven
Can you show us the code that runs after each of the Lookups?
Steven
A short post is a good post.
-
- Posts: 58
- Joined: Mon Sep 09, 2019 8:20 am
Re: Button to clone records in the subform
first lookup
second lookup
Code: Select all
$l = nuLookupRecord();
nuSetFormValue("pne_misura", $l->mis_misura);
Code: Select all
$lu = nuLookupRecord();
nuSetFormValue("pne_modello", $lu->mod_modello);
$sql = "SELECT * FROM t_marche WHERE t_marche.mar_id = ?";
$risultato = nuRunQuery($sql,array($lu->mod_id_marca));
if (db_num_rows($risultato) == 1) {
$r = db_fetch_object($risultato);
nuDebug($r);
nuSetFormValue("pne_marca", $r->mar_marca);
}
-
- Posts: 58
- Joined: Mon Sep 09, 2019 8:20 am
Re: Button to clone records in the subform
I think I solved it, or at least for the moment it works, I eliminated the 2 lookup objects found in columns 1 and 3 from the copy. this way it seems to work
thanks for your help!
Code: Select all
function cloneMe(id){
var f = $('#' + id).attr('data-nu-form');
var o = nuSubformObject(f);
var p = $('#' + id).attr('data-nu-prefix');
var r = Number(p.substr(-3)); //-- get the row number of the button clicked
var b = f + nuPad3(o.rows.length - 1); //-- bottom empty row
var d = o.rows[r]; //-- get values from that row
var s = o.fields; //-- get destination fieldnames for those values
for(var i = 2 ; i < s.length-1 ; i++){ //-- loop from THIRD fields
if(i != 3){ // to the second lookup column I do nothing
nuSetValue(b + s[i], d[i]);
}
}
}
-
- Posts: 58
- Joined: Mon Sep 09, 2019 8:20 am
Re: Button to clone records in the subform
I will gladly do it. but I sang victory too soon. there is another little problem. now the button works perfectly, but when i save the last cloned row it is not saved
-
- nuBuilder Team
- Posts: 4292
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 444 times
- Contact:
Re: Button to clone records in the subform
This is strange. Since nuSetValue() marks those fields as "edited" these changes ought to be saved to the database.
-
- Posts: 58
- Joined: Mon Sep 09, 2019 8:20 am
Re: Button to clone records in the subform
I'm not understanding anything anymore, now it seems to work fine without having changed anything