reference to current record

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

reference to current record

Postby kurisusan » Fri Dec 07, 2007 5:29 pm

Hi,

I would like to get a reference to the current record regardless of whether I'm in the 'view' page of a record or in of its related record 'list' pages. The $record parameter passed to the delegate class methods unfortunately changes to the first item of the related records table although the $_tablename stays the same.
Will I need to check the -action var and handle that myself?

Regards, Christian
kurisusan
 
Posts: 25
Joined: Sat Oct 27, 2007 2:40 am

Postby shannah » Fri Dec 07, 2007 6:54 pm

The current record should always be retrievable using:
Code: Select all
$app =& Dataface_Application::getInstance();
$record =& $app->getRecord();
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby kurisusan » Sat Dec 08, 2007 3:38 am

Unfortunately not. $record still references the first item of the related tables when leaving the 'view' page of a record.

Christian
[/quote]
kurisusan
 
Posts: 25
Joined: Sat Oct 27, 2007 2:40 am

Postby shannah » Sat Dec 08, 2007 4:09 am

Can you elaborate on your situation. I'm no longer sure I understand what you mean.

e.g.

the $app->getRecord() will never return any records from a related table. It will only return a record from the current table.
If you are in the view tab it will return the record being viewed.
If you are in one of its relationship tabs, it will still return the record being viewed (which is the parent of the related records).
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby kurisusan » Sat Dec 08, 2007 5:27 am

If you are in the view tab it will return the record being viewed.
If you are in one of its relationship tabs, it will still return the record being viewed (which is the parent of the related records).

Well, here it won't. I check that, e.g. by placing a
Code: Select all
echo $record->getID();

somewhere in the getParent() delegate class method and the id changes when switching from the 'view' tab to one of the related table views. This happens both when using the $record parameter of the getParent() method and using the app's getRecord() method.

I'll try to setup an online example.

Christian
kurisusan
 
Posts: 25
Joined: Sat Oct 27, 2007 2:40 am

Postby shannah » Sat Dec 08, 2007 1:25 pm

Are you referring to the situation after you have already clicked on one of the related records and are now viewing it?

If so, then it will show *that* record (i.e. the related record), which is now the current record.
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby kurisusan » Sat Dec 08, 2007 7:10 pm

Are you referring to the situation after you have already clicked on one of the related records and are now viewing it?


No, this already happens when just clicking on the notebook tab of one of the related records.

Christian
kurisusan
 
Posts: 25
Joined: Sat Oct 27, 2007 2:40 am

working sample

Postby kurisusan » Sat Dec 08, 2007 8:50 pm

I made an online sample to demonstrate the problem: www.hoc.net/sandbox/test

From the countries tables select 'Japan', then switch between the view and the 'cities' tab and have a look at the information given just below the nav_menu. You'll see that the id of the record changes.

The status line is created like this:

class tables_countries {
function block__after_nav_menu(){
$app =& Dataface_Application::getInstance();
$record =& $app->getRecord();
echo "current record's id is: ".$record->val('id');
echo ", tablename: ".$record->_tablename;
}
}
?>


Tell me if you need more information.

Christian
kurisusan
 
Posts: 25
Joined: Sat Oct 27, 2007 2:40 am

Postby shannah » Sun Dec 09, 2007 2:22 am

Thanks. This problem appears to be specific to 0.7.1 as my development version doesn't exhibit this problem (but i can confirm it when running 0.7.1).

I have filed a bug report on this issue:
http://bugs.weblite.ca/view.php?id=51

I have uploaded a patch there to fix this issue for dataface 0.7.1.
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby kurisusan » Sun Dec 09, 2007 2:30 am

Thanks!
kurisusan
 
Posts: 25
Joined: Sat Oct 27, 2007 2:40 am


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 28 guests

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