Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

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

Add value manually to many_many_extrafields


Reply


2 Posts   357 Views

Avatar
khanhdeux

Community Member, 13 Posts

20 December 2013 at 1:51am

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

Avatar
kinglozzer

Community Member, 175 Posts

20 December 2013 at 4:33am

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