List: New Row Form with Copy of Data from existing Row [SOLVED]

vivoices

New Member
Hi,
I want to add a button similar to the button of the "listplugin-copy" to each row of a list but instead of copying a row, the standard "Add Row Form" should be opened with a copy of the data of the given existing row.

That way the user is able to change the data before creating the new row.

Any ideas how to achieve this?

Thanks,
Udo
 
Will try using a JS button in the list, loading the form with a query string including the index of old row data.
Then load the old row data via an AJAX call and pre-populate the form fields with jQuery(document).ready(function(){} in the form's js file.

Any better ideas are appreciated.
 
This code might be help. Use at PHP list plugin.

PHP:
$app = JFactory::getApplication();
$input = $app->input;
$ids = $input->get('ids', array(), 'array');
$db = JFactory::getDBO();
$sql = "INSERT INTO sample (`state`, `city_town`) SELECT `state`, `city_town` FROM `sample` WHERE id IN (" . implode(',', $ids) . ")";
$db->setQuery($sql);
$db->execute();
 
Thanks myfatebiz,
that will work if I would not mind creating a new row and edit the data afterwards.

My app does not allow to delete rows, so I need the possibility to cancel without creating a db entry.

The JS button / AJAX approach is looking good so far.
Will let you know if and how it works when finished.
 
The concept described above works great.
A js list plugin creates a button for every row. To load the form and populate with data from existing row(s), I include Query parameters of the requested row ids and an indication param / value pair to the URL.
Code:
document.location.href = 'http://xyz.com/info/messages-cat/form/4/?xyz=uvw&rst=' + ids.join('q');
Now the form's javascript requests the data for the given rows via AJAX triggered by the indication param / value pair and updates a number of fields in the new form.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top