Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

TreeMultiselectField - level 3 not loading


Reply


6 Posts   1213 Views

Avatar
borriej

Community Member, 267 Posts

30 May 2011 at 9:04pm

Edited: 16/06/2011 12:32am

Hello,

i have a multi language website. a page class called 'product' and a class called 'technology'. product has a many_many relation to technology. with a TreeMultiselectField you can select the technology page, this all works in English (default) but in other languages i cant load level 3 pages...

[edit] some english pages do load, some don't, so its not a translate error

<?php
class Product extends Page {
   static $db = array(

      );
   
   static $has_one = array(

   );
   static $many_many = array(
      'Technologys' => 'Technology'
   );

   public function getCMSFields() {
      $fields = parent::getCMSFields();
      $fields->addFieldToTab('Root.Content.Technology', new TreeMultiselectField('Technologys', 'Select multiple technologys<br><i>Will be displayed on the product page</i>', 'Technology'));
      return $fields;
   }
}
class Product_Controller extends Page_Controller {

}

class Technology extends Page {
   static $belongs_many_many = array(
      'Products' => 'Product'
   );
   static $has_one = array(
      'Foto1' => 'Image',
   );
   function getCMSFields() {
      $fields = parent::getCMSFields();
      $fields->addFieldToTab("Root.Content.Images", new ImageField('Foto1', 'Photo 1'));
      return $fields;
   }
}
class Technology_Controller extends Page_Controller {}

Error

error [30-May-2011 10:48:50] Error at \sapphire\forms\TreeDropdownField.php line 205: Uncaught Exception: TreeDropdownField->tree(): the object #838 of type Technology could not be found

Avatar
borriej

Community Member, 267 Posts

14 June 2011 at 11:50pm

up!
Still have this error.. what to do?

Avatar
martimiz

Forum Moderator, 1132 Posts

15 June 2011 at 9:57pm

If this is indeed a locale issue, then maybe first start by checking if there is indeed a Technology record that has ID = 838 in your database and then check the locale of that Page. If it exists, check the locale and see if the record does actually belong to the custom locale...

Avatar
borriej

Community Member, 267 Posts

16 June 2011 at 12:24am

Ok i've checked:

i've got a table 'technology'
content of table:

ID    Foto1ID
214   0
217   0
218   0
219   137
220   138
222   0
835   137
837   137
839   137
841   137
843   137
1009   138
1010   138
1011   138
1012   138
1013   138
1184   0
1185   0
1186   0
1187   0
1188   0
2364   0

and i've got a table called 'product_technologys'

content of table:

ID    ProductID    TechnologyID
1   216   219
2   216   220
3   216   221
4   216   222
5   229   219
6   229   220
7   233   219
8   233   220
9   230   220

When i open an english product page with the ID 233 i can fold out the sitetree.. and view the technologys pages.
This works (i guess) because it already has a existing relation.

When i open an english product page with ID 634 and open the TreeMultiselectField, I can view level 1 pages, open technology page, see the level 2 pages, click exapand icon (+) again.. but then again the error:

Error at \sapphire\forms\TreeDropdownField.php line 205: Uncaught Exception: TreeDropdownField->tree(): the object #218 of type Technology could not be found (http://www.url.com/sapphire/main.php?url=/admin/EditForm/field/Technologys/tree/218&locale=en_US&)

I dont know what is causing this error, i must be able to view the sitetree before i can create relations between pages..

Avatar
borriej

Community Member, 267 Posts

16 June 2011 at 12:26am

The problem also occurs on the default English website.

Avatar
borriej

Community Member, 267 Posts

16 June 2011 at 12:55am

i Think ive solved it

replaced

$fields->addFieldToTab('Root.Content.Technology', new TreeMultiselectField('Technologys', 'Select multiple technologys<br><i>Will be displayed on the product page</i>', 'Technology'));

for

$fields->addFieldToTab('Root.Content.Technology', new TreeMultiselectField('Technologys', 'Select multiple technologys<br><i>Will be displayed on the product page</i>', 'SiteTree'));