Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » DataObject, ManyMany, and inline tickboxes

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1 2
Go to End
Author Topic: 3488 Views
  • Double-A-Ron
    Avatar
    Community Member
    604 Posts

    Re: DataObject, ManyMany, and inline tickboxes Link to this post

    Hi mate,

    Sorry for the delay. I've had to find time to install a fresh sandbox just to test this thing.

    Not sure where you got the incorrect filename thing from. The file is named the same as the class.

    Anyway, here is what I did to test the above code:

    1. Install fresh 2.3.2
    2. Install swfupload - dev/build
    3. Install dataobject_manager - dev/build
    4. Add TwoColumnPage.php and SideBarBlock.php to mysite/code
    5. Add SortableDataObject::add_sortable_class('SideBarBlock'); to dataobject_manager/_config.php
    6. dev/build - confirm SortOrder is being added to SideBarBlock table.
    7. Add new TwoColumnPage page to the CMS. Go to SideBarBlocks tab and add 3 entries.
    8. Activate Drag and Drop reordering and reorder items just added.
    9. Save and Publish, reload CMS

    Problem is exactly the same. The SortOrder is updating just fine in the table, but in the CMS the sorting is only done on the ID (confirmed by manually editing the IDs in the table).

    Also, as before, clicking on table column headers does no sorting either. Here is the call the CMS is making when I try to sort on "Header" column: http://silverstripe.localhost/admin/EditForm/field/SideBarBlocks?ctf[SideBarBlocks][per_page]=10&ctf[SideBarBlocks][showall]=0&ctf[SideBarBlocks][sort]=Header&ctf[SideBarBlocks][sort_dir]=ASC&ctf[SideBarBlocks][search]=&ctf[SideBarBlocks][filter]=

    Here is the precise files I am using. http://www.zanzomedia.com/mac/code.rar

    I can't for the life of me work this out.

    Aaron

  • UncleCheese
    Avatar
    4085 Posts

    Re: DataObject, ManyMany, and inline tickboxes Link to this post

    I couldn't open that file. Could you paste the code in here?

  • Double-A-Ron
    Avatar
    Community Member
    604 Posts

    Re: DataObject, ManyMany, and inline tickboxes Link to this post

    Hi mate, here are full copy/pastes

    SideBarBlock.php

    class SideBarBlock extends DataObject {

    static $db = array(
    'Header' => 'Text',
        'Content' => 'HTMLText',
    );

    static $has_one = array (
    );

    static $belongs_many_many = array(
    'TwoColumnPages' => 'TwoColumnPage'
    );
       
    public function getCMSFields_forPopup()
        {
          return new FieldSet(
             new TextField('Header', 'Block Header'),
             new SimpleHTMLEditorField('Content','Block Content', array (
             'css' => 'mysite/css/side-bar-blocks.css',
                'increaseFontSize' => false,
                'decreaseFontSize' => false,
                'justifyLeft' => false,
                'justifyRight' => false,
                'justifyFull' => false,
                'justifyCenter' => false
             ))
          );
       }

    }

    TwoColumnPage.php

    class TwoColumnPage extends Page {
       
       static $many_many = array(
          'SideBarBlocks' => 'SideBarBlock'
       );      
       
       public static $db = array(
       );
       
       public static $has_one = array(
       );
       
       public function getCMSFields()
       {
          $fields = parent::getCMSFields();

             $fields->addFieldToTab("Root.Content.Sidebar", new ManyManyDataObjectManager(
                $this,
                'SideBarBlocks',
                'SideBarBlock',
                array('Header' => 'Header'),
                'getCMSFields_forPopup',
                '',
                'SortOrder'
             ));
          
          return $fields;
          
       }
       
    }

    class TwoColumnPage_Controller extends Page_Controller {

       static $allowed_actions = array('SearchForm');
       
       public function init() {
          parent::init();

          // Note: you should use SS template require tags inside your templates
          // instead of putting Requirements calls here. However these are
          // included so that our older themes still work
          /*Requirements::themedCSS("layout");
          Requirements::themedCSS("typography");
          Requirements::themedCSS("form"); */
       }
       
       /**
        * Site search form
        */
       function SearchForm() {
          $searchText = isset($_REQUEST['Search']) ? $_REQUEST['Search'] : 'Search';
          $fields = new FieldSet(
           new TextField("Search", "", $searchText)
           );
          $actions = new FieldSet(
           new FormAction('results', 'Search')
           );

           return new SearchForm($this, "SearchForm", $fields, $actions);
       }
       
       /**
        * Process and render search results
        */
       function results($data, $form){
           $data = array(
           'Results' => $form->getResults(),
           'Query' => $form->getSearchQuery(),
           'Title' => 'Search Results'
           );

           return $this->customise($data)->renderWith(array('Page_results', 'Page'));
       }
       
    }

    Cheers
    Aaron

  • UncleCheese
    Avatar
    4085 Posts

    Re: DataObject, ManyMany, and inline tickboxes Link to this post

    I've copied your code into my sandbox area. Could you log in and tell me if this is the expected behavior?

    http://dataobjectmanager.carlinowebdesign.com
    u: admin
    p: password

    The page is the last one in the site tree, called "TEST"

  • Double-A-Ron
    Avatar
    Community Member
    604 Posts

    Re: DataObject, ManyMany, and inline tickboxes Link to this post

    Thanks for persisting with this mate.

    Yes, that behaviour is as expected. Did you just drop my code into mysite? I take it that the tabs Widgets and Foo are page of your Page class.

    If so, I don't know what else I'm doing wrong. Even the column sort works for you.

    I've found the same effect on three different machines. (2x Wamp, 1x *Nix).

    I'm using the trunks of dataobject_manager and swfupload. Can't think what else beyond the step by step list above that I've missed.

    I will try again on the *Nix box.

    Aaron

    3488 Views
Page: 1 2
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.