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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Form Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Forms for $many_many_extraFields problem


Go to End


1273 Views

Avatar
khanhdeux

Community Member, 13 Posts

25 April 2014 at 11:27pm

Hi i have a problem regarding form
i have 2 Dataobjects
class Channel extends DataObject {

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

class Video extends DataObject {
private static $belongs_many_many = array(
'VideoCategories' => 'VideoCategory',
'Channels' => 'Channel',
);

In the form i used
$ChannelList = Channel::getByMember()->map('ID', 'ChannelTitle');
$fields = new FieldList(
new TextField('VideoTitle', 'Video title'),
new TextField('VideoDescription', 'Video description'),
$VideoFile = new BootstrapUploadField('VideoFile', 'Upload Video File'),
new CheckboxSetField('Channels', 'Choose channels', $ChannelList)
);
$this->loadDataFrom(singleton('Video'));

Its working properly but i dont know how to pop up and show the publishedDate and unpublishedDate for each channel. Any solution is really appreciated. Thanks