BUG Fixing misspelled variable not being able to select subsite for Folder

This commit is contained in:
Sean Harvey 2013-02-04 15:21:08 +13:00
parent bf1390f0f8
commit 0968eac399
2 changed files with 21 additions and 6 deletions

View File

@ -30,13 +30,13 @@ class FileSubsites extends DataExtension {
function updateCMSFields(FieldList $fields) {
if($this->owner instanceof Folder) {
$sites = Subsite::accessible_sites('CMS_ACCESS_AssetAdmin');
$dropdownValues = array();
$dropdownValues[0] = 'All sites';
$values = array();
$values[0] = 'All sites';
foreach ($sites as $site) {
$dropDownValues[$site->ID] = $site->Title;
$values[$site->ID] = $site->Title;
}
ksort($dropdownValues);
if($sites)$fields->push(new DropdownField("SubsiteID", "Subsite", $dropdownValues));
ksort($values);
if($sites)$fields->push(new DropdownField('SubsiteID', 'Subsite', $values));
}
}

View File

@ -53,6 +53,21 @@ class FileSubsitesTest extends BaseSubsiteTest {
$file->onAfterUpload();
$this->assertEquals($folder->SubsiteID, $file->SubsiteID);
}
function testSubsitesFolderDropdown() {
$this->objFromFixture('Member', 'admin')->logIn();
$file = new Folder();
$this->assertEquals(array(
'Main site',
'Template',
'Subsite1 Template',
'Subsite2 Template',
'Test 1',
'Test 2',
'Test 3'
), $file->getCMSFields()->dataFieldByName('SubsiteID')->getSource());
}
}