duplicate a record

A place for users and developers of the Xataface to discuss and receive support.

duplicate a record

Postby gsilvis » Thu Feb 25, 2010 4:17 pm

I want to be able to duplicate one record of a table (not a whole set). One way would be a button or action from the Edit screen, using the field data displayed (ie, the record I want to duplicate would be displayed). The key for the database is not shown in the editable fields. One of the fields is a blob, the rest text.

Suggestions on how I could do this?

Many thanks
George
gsilvis
 
Posts: 20
Joined: Sat Dec 05, 2009 4:52 pm

Re: duplicate a record

Postby shannah » Thu Feb 25, 2010 5:41 pm

The easiest thing would be to just use the copy set action, but on a single record.
index.php?-action=copy_replace&--copy=1&myid=10

This would give you the copy form for only the record with myid=10.
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: duplicate a record

Postby gsilvis » Thu Feb 25, 2010 9:03 pm

shannah wrote:The easiest thing would be to just use the copy set action, but on a single record.
index.php?-action=copy_replace&--copy=1&myid=10

This would give you the copy form for only the record with myid=10.


So, if my key field is named "key" then I would need to know the value of the field for the current record. Is that at hand?

Thanks again,
George
gsilvis
 
Posts: 20
Joined: Sat Dec 05, 2009 4:52 pm

Re: duplicate a record

Postby shannah » Fri Feb 26, 2010 8:28 am

Code: Select all
$currentRecord = Dataface_Application::getInstance()->getRecord();
$keyval = $currentRecord->val('key');
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: duplicate a record

Postby gsilvis » Sun Feb 28, 2010 8:51 am

Ok, got it working. To the cards.php file I added the following code:

Code: Select all
        // Duplicate Record function
        function block__after_edit_record_form() {
              $currentRecord = Dataface_Application::getInstance()->getRecord();
              $keyval = $currentRecord->val('key');                   
              echo("<a href=\"http://www.gasilvis.com/Eggen/index.php?-action=copy_replace&--copy=1&key=$keyval\">Duplicate this record </a>");
        }


This gives me a clickable point at the bottom of the edit form that will duplicate the current record.

A side affect of using the action-copy_replace is that the current set is redefined at completion to a set with one record, the new record. It would be nicer to still be in the edit page with the current set increased by the copied record.

Thanks again for the help,
George
gsilvis
 
Posts: 20
Joined: Sat Dec 05, 2009 4:52 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 25 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved