Jump to:

23358 Posts in 17874 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » PopulateDefault a DataObjectManager List

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: 888 Views
  • eceers
    Avatar
    Community Member
    24 Posts

    PopulateDefault a DataObjectManager List Link to this post

    Hi,

    My client has a need to be able to build a DataObjectManager list of default values.

    I thought I was going to be able to use something like;

       public static $db = array(
          'TextBox1' => 'Text',
          'TextBox2' => 'Text',
          'TextBox3' => 'Text'      
       );
       
       public static $has_many = array(
          'ProjectFields1' => 'ProjectField'
       );
       
       public function populateDefaults() {
           $this->TextBox1 = 'Eggs Are Great';
           $this->TextBox2 = 'Patty is a winner';
          $this->TextBox3 = 'Maya steps very loudly';
          
          $this->ProjectFields1 = array(
             array(
                'Title'=>'Question 01',
                'Description'=>'Lorem ipsum dolor sit amet, consectetur adipisicing elit.'
                ),
             array(
                'Title'=>'Question 02',
                'Description'=>'Lorem ipsum dolor sit amet, consectetur adipisicing elit.'
                )   
             );   
        parent::populateDefaults();
       }

    but no luck

    The DataObject I'm using looks like

    class ProjectField extends DataObject {

       static $db = array(
          'Title' => 'Text',
          'Description' => 'HTMLText',
       );

       static $has_one = array(
           'ProjectField' => 'GeneralPage',
       );

       function getCMSFields_forPopup() {
          $fields = new FieldSet();
          $fields->push( new TextField( 'Title' ) );
          $fields->push( new SimpleWysiwygField('Description'));
          return $fields;
       }   
    }

    Two questions I suppose, am I heading in the right direction? if so could possibly help me over the edge?

    Second, is it all possible? I would of thought so.

    Any help would be greatly appreciated.

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