[eluser]misplacedme[/eluser]
You're going to have to use javascript to do this. Anything dynamic on the user side is going to be javascript. I use jquery for all my javascript(because it's quicker), so that's how my example is going to be.
Step 1: Use javascript to open a new window in the page that has the form
Code:
<a href="#" id="product_search">Search Products</a>
$('#product_search').click(function(){
window.open('/url/to/searchpage','ProductSearch','width=600,height=600');
return false
})
Step 2: In /url/to/searchpage, make it search the products listings like normal. Each product will have a link to add.
Step 3: In the link to add, grab all the data you're going to populate the form with. Make sure it is a single level array. Use json_encode to convert it to javascript and print it out.
Here is an example of the page that adds the item.
Code:
<?
//Code to get the data here
$data = json_encode($this->db->row_array());
?>
<html>
<head>
[removed][removed]
[removed]
$(document).ready(function) {
var data = <?=$data?>;
for (key in data) { Loop through the array. I'm going to pretend your form fields are named the same as the database entry
$('input[name='+key+']',window.opener.document).val(data[key]);
}
window.close();
}
[removed]
That will populate the opening window with your data.