Jump to:

23459 Posts in 18906 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » Add value manually to many_many_extrafields

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: 214 Views
  • khanhdeux
    Avatar
    Community Member
    13 Posts

    Add value manually to many_many_extrafields Link to this post

    Hi team,
    I have a problem when editing the form (not gridfield at backend). I have
    class Channel extends DataObject {

    private static $db = array(
    'ChannelTitle' => 'Varchar(255)',
    'ChannelDescription' => 'Text'
    );
    private static $many_many = array(
    'Videos' => 'Video'
    );
    private static $summary_fields = array(
    'ChannelTitle'
    );
    private static $many_many_extraFields = array(
    'Videos' => array(
    'PublishedDate' => 'SS_Datetime',
    'UnpublishedDate' => 'SS_Datetime'
    )
    );

    }
    And
    class Video extends DataObject {

    const IMAGE_MAX_FILE_SIZE = 1000000;
    const VIDEO_MAX_FILE_SIZE = 500000000;

    public static $image_extension = array('jpg', 'jpeg', 'gif', 'png');
    public static $video_extension = array('mp4', 'ogg', 'avi', 'mov');
    private static $db = array(
    'VideoTitle' => 'Varchar(255)',
    'VideoDescription' => 'Text'
    );
    private static $has_one = array(
    'VideoImage' => 'Image',
    'VideoFile' => 'File',
    'Owner' => 'Member'
    );
    private static $has_many = array(
    'Comments' => 'VideoComment'
    );
    private static $belongs_many_many = array(
    'VideoCategories' => 'VideoCategory',
    'Channels' => 'Channel',
    );
    );

    Now i want to add value manually to table Channel_Videos for the doeditform. I tried with getManyManyComponent without being successful. Any help really appreciate

  • kinglozzer
    Avatar
    Community Member
    139 Posts

    Re: Add value manually to many_many_extrafields Link to this post

    Hi khanhdeux,

    Perhaps this will be of some help: http://api.silverstripe.org/3.1/class-ManyManyList.html#_add

    For example:

    $videos = $this->Videos();
    $videos->add($myVideo, array('PublishedDate' => '12/12/2013 11:11:11));

    Loz

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