Jump to:

7937 Posts in 1537 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » getCMSFields

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 1683 Views
  • KrassavaBoy
    Avatar
    Community Member
    7 Posts

    getCMSFields Link to this post

    Please, Help. How I can use 2 addFieldToTab with 1 getCMSFields

    <?php
    /**
    * Defines the HomePage page type
    */

    class HomePage extends Page {

    static $db = array (
          'SolutionName' => 'Text'
       );
       
    static $has_many = array(
          'Slideshows'=>'Slideshow'
    );

       public function getCMSFields()
       {
          $f = parent::getCMSFields();
          $manager = new FileDataObjectManager(
             $this, // Controller
             'Slideshows', // Source name
             'Slideshow', // Source class
             'FullImage', // File name on DataObject
             array(
                'Title' => 'Title',
                'Description' => 'Description'
             ), // Headings
             'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
             // Filter clause
             // Sort clause
             // Join clause
          );
          
          // If undefined, all types are allowed. Pass with or without a leading "."      
          $manager->setAllowedFileTypes(array('jpg','png'));
          
          // Label for the upload button in the popup
          $manager->setBrowseButtonText("Upload (JPG or PNG only)");
          
          // In grid view, what field will appear underneath the icon. If left out, it defaults to the file title.
          $manager->setGridLabelField('Name');
          
          // Plural form of the objects being managed. Used on the "Add" button.
          // If left out, this defaults to [MyObjectName]s
          $manager->setPluralTitle('Slideshows');
                
          $f->addFieldToTab("Root.Content.Slideshows", $manager);
          $f->addFieldToTab("Root.Content.Main", new TextField('SolutionName'), 'Content');

          return $f;
       }
    }

    class HomePage_Controller extends Page_Controller {

    }
    ?>

  • UncleCheese
    Avatar
    4085 Posts

    Re: getCMSFields Link to this post

  • KrassavaBoy
    Avatar
    Community Member
    7 Posts

    Re: getCMSFields Link to this post

    Sorry, but how does it help me? In this code))

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