Jump to:

23490 Posts in 18996 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » TreeMultiselectField - level 3 not loading

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

Page: 1
Go to End
Author Topic: 1174 Views
  • borriej
    Avatar
    Community Member
    267 Posts

    TreeMultiselectField - level 3 not loading Link to this post

    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

  • borriej
    Avatar
    Community Member
    267 Posts

    Re: TreeMultiselectField - level 3 not loading Link to this post

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

  • martimiz
    Avatar
    Forum Moderator
    1086 Posts

    Re: TreeMultiselectField - level 3 not loading Link to this post

    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...

  • borriej
    Avatar
    Community Member
    267 Posts

    Re: TreeMultiselectField - level 3 not loading Link to this post

    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..

  • borriej
    Avatar
    Community Member
    267 Posts

    Re: TreeMultiselectField - level 3 not loading Link to this post

    The problem also occurs on the default English website.

  • borriej
    Avatar
    Community Member
    267 Posts

    Re: TreeMultiselectField - level 3 not loading Link to this post

    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'));

    1174 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.