Welcome to the nuBuilder Forums!

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

RecordId For Subform Rows

Post Reply
hunt342
Posts: 2
Joined: Sat Jul 30, 2011 7:08 am

RecordId For Subform Rows

Unread post by hunt342 »

When a subform is saved I want to update a couple fields [that are not in the subform] for that record row in the DB. To do this I need the primary key for that subform row. I've added the code in the "After Save" Section Of the "Edit Code" for that form. To get the primary I'm querying the database.

I was wondering if there was a better way to get the primary key of the subform row in the "After Save".

Like we do for the forms using Hash Variable / $_POST [#recordID# / $recordID]
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: RecordId For Subform Rows

Unread post by admin »

hunt342,

This is the main place you can't use hash variables.

The simple reason is that hash variable values are inserted into the PHP code just before it is run (making them static)

Here's a bit of code that prints out results to the table zzsys_trap (I created it from he invoice form in the sampledebtors screen)...

Code: Select all

$subformname     = "FMinvoice_item";
$rows            = $_POST["rows" . $subformname];

nuDebug($rows);  

for($i = 0 ; $i < $rows ; $i ++){

     $fieldname  = 'FMinvoice_item' . substr('000'.$i, -4)  . 'tri_amount'; 

     nuDebug($fieldname . ' ' . $_POST[$fieldname]);  
}

I hope this helps..

Steven
Post Reply