Strange behaviour in related tab

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

Strange behaviour in related tab

Postby jay » Mon Dec 07, 2009 11:23 am

Hi, I'm setting up a back-end for an image gallery site. It is simply composed of photos and photo galleries, each in one table (namely, photos and galleries).
The photos table has an FK to the galleries table via a field "gallery_id", so I wrote this relationships.ini file in the tables/galleries folder:
Code: Select all
[photos]
photos.gallery_id = "$id"


So the photos tab appears inside the details of a gallery record, but if I do the following from there:
1. click the photos tab
2. click the link named "Add New Photos Record"
3. fill in the photo fields (one is an image which will be stored on disk; the photo and photo_mimetype fields exist and seem to be ok)
4. save the new photo record
...then I'm directed to the photos tab again, but this time it will display "No records matched your request." instead of the table of photos and the left and right arrows for the details view have disappeared. The new photo record was created, though.

A few images to illustrate the situation:
1. before editing >> http://picasaweb.google.com/jforns/Xata ... 3973914978
2. during editing >> http://picasaweb.google.com/jforns/Xata ... 3238544466
3. result >> http://picasaweb.google.com/jforns/Xata ... 7219662514

Also, if I click on the "edit" tab, I can edit the "bodas" gallery record, but if I click on the "photos" tab again (without saving the gallery), it still shows empty.

BTW, as you can see from the screen shots, a "Save" button appears in each fieldgroup, when just a single Save button should appear at the bottom of the form.

I guess this is a bug, but maybe I'm doing something wrong... Steve?

Rgds, J.
jay
 
Posts: 13
Joined: Wed Apr 01, 2009 3:39 am

Postby shannah » Mon Dec 07, 2009 6:12 pm

What does the query string of the URL look like for this screen?
http://picasaweb.google.com/jforns/Xata ... 7219662514
?
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby jay » Thu Dec 10, 2009 4:40 am

jay
 
Posts: 13
Joined: Wed Apr 01, 2009 3:39 am

Postby jay » Thu Dec 10, 2009 9:33 am

Here's another way to reproduce the issue:

* open the galleries table (url will be http://localhost/xxx/index.php?-table=galleries)

* click on any gallery, which directs to editing it (url will be http://localhost/xxx/index.php?-table=g ... s%3Fid%3D1)

* click on the photos tab (url will be http://localhost/xxx/index.php?-action= ... hip=photos), I can see the photos of this gallery, ok

* browse to the next gallery with the right arrow button from the controller toolbar (url will be http://localhost/xxx/index.php?-action= ... hip=photos), at this point no photo is shown even though this second gallery has photos

No more photos will show in the photos tab of a gallery until I go back to the galleries table.

Hope this helps, J.
jay
 
Posts: 13
Joined: Wed Apr 01, 2009 3:39 am

Postby shannah » Fri Dec 11, 2009 10:13 am

Have you defined any permissions or security filters in the delegate classes? Or have you defined any code that modifies the GET or REQUEST or query params programmatically?
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby jay » Sun Dec 13, 2009 10:04 am

No, I don't use any security facilities.

For the galleries table there's just a fields.ini and this relationships.ini:
Code: Select all
[photos]
photos.gallery_id = "$id"

For the photos table there's a fields.ini file, this valuelists.ini:
Code: Select all
[Galleries]
__sql__ = "SELECT id, name_es FROM galleries ORDER BY name_es"
and this photos.php:
Code: Select all
class tables_photos
{

   function getTitle(&$record)
   {
      return $this->_fmtDesc($record->val('desc_es'), 30);
   }

   function titleColumn()
   {
      return 'CONCAT(SUBSTR(desc_es, 1, 29), "...")';
   }
   
   function photo__renderCell(&$record)
   {
      $filename = $record->val('photo');
      if ($filename)
      {
         return '<img>';
      }
      else
      {
         return "";
      }
   }
   
   function desc_es__renderCell(&$record)
   {
      return $this->_fmtDesc($record->val('desc_es'));
   }
   
   function desc_en__renderCell(&$record)
   {
      return $this->_fmtDesc($record->val('desc_en'));
   }
   
   function desc_ca__renderCell(&$record)
   {
      return $this->_fmtDesc($record->val('desc_ca'));
   }
      
   function _fmtDesc(&$desc, $len=80)
   {
      if (strlen($desc) > ($len+3))
      {
         return substr($desc, 0, $len)."...";
      }
      return $desc;
   }
   
   function valuelist__VocBool()
   {
      return array("0" => "No", "1" => "Sí");
   }

}



That's all.
jay
 
Posts: 13
Joined: Wed Apr 01, 2009 3:39 am

Postby shannah » Mon Dec 14, 2009 10:26 am

I can't see any reason for what you're experiencing then.
What versions of:
PHP
MySQL
Web Server
OS
Xataface

are you using?
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby jay » Wed Dec 16, 2009 3:33 am

Hi Steve, I finally found what was causing the issue: I wrote this custom SQL statement in the tables/galleries/fields.ini:
Code: Select all
__sql__="SELECT *, (SELECT COUNT(*) FROM photos WHERE gallery_id=g.id) as photo_cnt FROM galleries g"
because I needed a column in the galleries grid that showed how many photos a gallery contains; if I remove this line everything is back to normal. I don't know whether this is a bug or not, I leave this up to you ;)

I guess I could achieve the same thing by using a view defined with the previous stmt, is there an alternative I could use from xataface?

Thanks for you help.
jay
 
Posts: 13
Joined: Wed Apr 01, 2009 3:39 am


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 30 guests

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