public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName('NotificationMembers');
     $fields->removeByName('CreatedByMemberID');
     $fields->addFieldToTab('Root.Main', new TextField('MemberNotificationTitle', 'User notification title'));
     $fields->addFieldToTab('Root.Main', new TextareaField('MemberNotificationMessage', 'User notification message (200) characters only'));
     // members - many_many relation
     $membersMap = Member::get()->sort('FirstName')->map('ID', 'FirstName')->toArray();
     $membersField = new ListboxField('NotificationMembers', 'Select users');
     $membersField->setMultiple(true)->setSource($membersMap);
     $fields->addFieldToTab('Root.Main', $membersField);
     return $fields;
 }
 public function updateCMSFields(FieldList $fields)
 {
     $localesNames = Fluent::locale_names();
     if (!$this->owner instanceof SiteConfig) {
         // If the ActiveLocales has been applied to SiteConfig, restrict locales to allowed ones
         $conf = SiteConfig::current_site_config();
         if ($conf->hasExtension('ActiveLocalesExtension') && $conf->ActiveLocales) {
             $localesNames = $conf->ActiveLocalesNames();
         }
     }
     // Avoid clutter if we only have one locale anyway
     if (count($localesNames) === 1) {
         return;
     }
     $fields->addFieldToTab('Root.Main', $lang = new ListboxField('ActiveLocales', _t('ActiveLocalesExtension.ACTIVELOCALE', 'Active Languages'), $localesNames));
     $lang->setMultiple(true);
     return $fields;
 }
Exemplo n.º 3
0
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName('FaqPageID');
     $fields->removeByName('FaqTags');
     $fields->removeByName('SortOrder');
     $fields->addFieldToTab('Root.Main', new TextField('Question', 'Question'));
     $fields->addFieldToTab('Root.Main', new HtmlEditorField('Answer', 'Answer'));
     // faq section - has_one relation
     $map = FaqSection::get()->sort('Title')->map('ID', 'Title');
     $field = new DropdownField('FaqSectionID', 'Faq section', $map);
     $field->setEmptyString('None');
     $fields->addFieldToTab('Root.Main', $field, 'Question');
     // faq tags - has_many relation
     $tagMap = FaqTag::get()->sort('Title')->map('ID', 'Title')->toArray();
     $tagsField = new ListboxField('FaqTags', 'Faq tags');
     $tagsField->setMultiple(true)->setSource($tagMap);
     $fields->addFieldToTab('Root.Main', $tagsField, 'Question');
     return $fields;
 }
 public function updateCMSFields(FieldList $fields)
 {
     $services = SiteConfig::config()->available_services;
     if (!$services) {
         $services = array_keys(self::listAvailableMediaServices());
     }
     if (in_array('twitter', $services)) {
         $fields->addFieldToTab('Root.Social', new TextField('TwitterUsername', _t('Socialstream.TwitterUsername', 'Twitter Username')));
     }
     if (in_array('twitter_hashtag', $services)) {
         $fields->addFieldToTab('Root.Social', new TextField('TwitterHashtag', _t('Socialstream.TwitterHashtag', 'Twitter Hashtag')));
     }
     if (in_array('facebook_page', $services)) {
         $fields->addFieldToTab('Root.Social', new TextField('FacebookPage', _t('Socialstream.FacebookPage', 'Facebook Page')));
     }
     if (in_array('vimeo', $services)) {
         $fields->addFieldToTab('Root.Social', new TextField('VimeoUsername', _t('Socialstream.VimeoUsername', 'Vimeo Username')));
     }
     if (in_array('youtube', $services)) {
         $fields->addFieldToTab('Root.Social', new TextField('YoutubeUsername', _t('Socialstream.YoutubeUsername', 'Youtube Username')));
     }
     if (in_array('dailymotion', $services)) {
         $fields->addFieldToTab('Root.Social', new TextField('DailymotionUsername', _t('Socialstream.DailymotionUsername', 'Dailymotion Username')));
     }
     if (in_array('rss', $services)) {
         $fields->addFieldToTab('Root.Social', new TextField('RssFeed', _t('Socialstream.RssFeed', 'Rss Feed')));
     }
     if (in_array('flickr', $services)) {
         $fields->addFieldToTab('Root.Social', new TextField('FlickrUsername', _t('Socialstream.FlickrUsername', 'Flickr Username')));
     }
     if (in_array('github', $services)) {
         $fields->addFieldToTab('Root.Social', new TextField('GithubUsername', _t('Socialstream.GithubUsername', 'Github Username')));
     }
     $fields->addFieldToTab('Root.Social', $wl = new ListboxField('LifestreamWhitelist', _t('Socialstream.LifestreamWhitelist', 'Lifestream Whitelist'), array_combine($services, $services)));
     $wl->setMultiple(true);
     $wl->setDescription('A list of services to display on the Lifestream. If left blank, all configured streams will be used.');
     $fields->addFieldToTab('Root.Social', new NumericField('LifestreamItems', _t('Socialstream.LifestreamItems', 'Lifestream Items')));
     return $fields;
 }
Exemplo n.º 5
0
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     if ($this->ID) {
         Session::set("FamilyMemberID", $this->ID);
     }
     if (Session::get("FamilyID")) {
         $this->FamilyID = Session::get("FamilyID");
         $fields->replaceField('FamilyID', new HiddenField('FamilyID'));
     }
     $dateOfBirth = new DateField('DateOfBirth', 'Date Of Birth');
     $dateOfBirth->setConfig('dateformat', 'dd-MM-yyyy');
     $dateOfBirth->setDescription('e.g. ' . date('d-m-Y'));
     $dateOfBirth->setAttribute('placeholder', 'dd-MM-yyyy');
     $fields->addFieldsToTab('Root.Main', $dateOfBirth);
     $genders = Config::inst()->get('FamilyMember', 'Gender');
     $gender = new OptionsetField("Gender", 'Gender', $genders);
     $fields->addFieldsToTab('Root.Main', $gender);
     $status = Config::inst()->get('FamilyMember', 'MartialStatus');
     $martialStatus = new OptionsetField("MartialStatus", 'Martial Status', $status);
     $fields->addFieldsToTab('Root.Main', $martialStatus);
     $fields->insertBefore(new Tab('Job', 'Job'), 'CommunityGroups');
     //Job GridField
     $jobGridFieldConfig = GridFieldConfig_RecordEditor::create();
     $jobList = Job::get()->filter(array('FamilyMemberID' => $this->ID))->sort('ID ASC');
     if ($jobList->count()) {
         $jobGridFieldConfig->removeComponentsByType('GridFieldAddNewButton');
     }
     $jobGridField = new GridField('Job', 'Job', $jobList, $jobGridFieldConfig);
     $fields->addFieldsToTab('Root.Job', array($jobGridField));
     $fields->insertBefore(new Tab('Health', 'Health'), 'CommunityGroups');
     //Health GridField
     $healthGridFieldConfig = GridFieldConfig_RecordEditor::create();
     $healthList = Health::get()->filter(array('FamilyMemberID' => $this->ID))->sort('ID ASC');
     if ($healthList->count()) {
         $healthGridFieldConfig->removeComponentsByType('GridFieldAddNewButton');
     }
     $healthGridField = new GridField('Health', 'Health', $healthList, $healthGridFieldConfig);
     $fields->addFieldsToTab('Root.Health', array($healthGridField));
     //Job GridField
     /*
     $communityGroupsCongfig = GridFieldConfig_RelationEditor::create();
     //$jobGridFieldConfig = GridFieldConfig_RecordEditor::create();
     $communityGroupsList = $this->CommunityGroups();
     $communityGroupsGridField = new GridField('CommunityGroups', 'Community Groups',
     	$communityGroupsList,
     	$communityGroupsCongfig);
     $fields->addFieldsToTab('Root.CommunityGroups', array(
     	$communityGroupsGridField
     ));
     */
     //CommunityGroups ListboxField
     $communityGroupsList = CommunityGroup::get()->map('ID', 'Title')->toArray();
     $communityGroupsField = new ListboxField($name = "CommunityGroups", $title = "Communtiy Groups", $communityGroupsList);
     $communityGroupsField->setMultiple(true);
     $fields->addFieldsToTab('Root.CommunityGroups', $communityGroupsField);
     //exit('dd');
     return $fields;
 }
 public function testSaveIntoManyManyRelation()
 {
     $article = $this->objFromFixture('ListboxFieldTest_Article', 'articlewithouttags');
     $articleWithTags = $this->objFromFixture('ListboxFieldTest_Article', 'articlewithtags');
     $tag1 = $this->objFromFixture('ListboxFieldTest_Tag', 'tag1');
     $tag2 = $this->objFromFixture('ListboxFieldTest_Tag', 'tag2');
     $field = new ListboxField("Tags", "Test field", DataObject::get("ListboxFieldTest_Tag")->map()->toArray());
     $field->setMultiple(true);
     // Save new relations
     $field->setValue(array($tag1->ID, $tag2->ID));
     $field->saveInto($article);
     $article = Dataobject::get_by_id('ListboxFieldTest_Article', $article->ID, false);
     $this->assertEquals(array($tag1->ID, $tag2->ID), $article->Tags()->sort('ID')->column('ID'));
     // Remove existing relation
     $field->setValue(array($tag1->ID));
     $field->saveInto($article);
     $article = Dataobject::get_by_id('ListboxFieldTest_Article', $article->ID, false);
     $this->assertEquals(array($tag1->ID), $article->Tags()->sort('ID')->column('ID'));
     // Set NULL value
     $field->setValue(null);
     $field->saveInto($article);
     $article = Dataobject::get_by_id('ListboxFieldTest_Article', $article->ID, false);
     $this->assertEquals(array(), $article->Tags()->sort('ID')->column('ID'));
 }