1. The basic use couldn't be more simple. Somewhere in your second form, (best near the top before other fields), just add this code:
<?php echo field_forwarder();?>
You'll get hidden fields printed out for every form element that was passed. if you have form elements that are ARRAYS, it works for those too.
2. Use other sources for field_forwarder()
What the function is looking at is the $_POST collection, which is an array. You can also use other arrays in place of this. Suppose you had an included file with the following array declared:
<?php $info['residence']['recent'] = "123 Main Street."; $info['residence']['previous'] = "1044 S. Fedora Drive"; $info['interests'][1] = 'hockey'; $info['interests'][2] = 'figure skating'; $info['name'] = 'Samuel "Sambo" Fullman'; $info['company'] = 'Compass Point Media'; ?>
To get this into fields, we'd just declare the following after the array has been declared:
<?php echo field_forwarder('info');?>
And instead of the form collection, it'll output the $info array as follows:
Two things to note here: 1) When you declare arrays in HTML form elements, you DON'T put quotes around string indexes, 2) the quotes for "Sambo" were replaced with ", otherwise the browser wouldn't know where the value ends.
My function handles arrays quite handily. In fact there is no real limit on the number of keys (indexes) that can be used. If you're actually strange enough to have an array element called: