Skip to content
Browse files

API CHANGE Switch usage from FieldSet to FieldList

  • Loading branch information...
1 parent 49866b2 commit 05e90838c066ae37b3c43b7fde4e2d18daad6fc7 @stojg stojg committed with stojg Oct 26, 2011
View
10 code/controllers/AssetAdmin.php
@@ -135,7 +135,7 @@ function UploadMetadataHtml() {
* Return the form object shown in the uploadiframe.
*/
function UploadForm() {
- $form = new Form($this,'UploadForm', new FieldSet(
+ $form = new Form($this,'UploadForm', new FieldList(
new HiddenField("ID", "", $this->currentPageID()),
new HiddenField("FolderID", "", $this->currentPageID()),
// needed because the button-action is triggered outside the iframe
@@ -148,7 +148,7 @@ function UploadForm() {
<p>" . _t('AssetAdmin.FILESREADY','Files ready to upload:') ."</p>
<div id=\"Form_UploadForm_FilesList\"></div>
")
- ), new FieldSet(
+ ), new FieldList(
));
// Makes ajax easier
@@ -228,7 +228,7 @@ function doUpload($data, $form) {
if($newFile = $folder->addUploadToFolder($tmpFile)) {
if(self::$metadata_upload_enabled && isset($processedData[$filePostId])) {
$fileObject = DataObject::get_by_id('File', $newFile);
- $metadataForm = new Form($this, 'MetadataForm', $fileObject->uploadMetadataFields(), new FieldSet());
+ $metadataForm = new Form($this, 'MetadataForm', $fileObject->uploadMetadataFields(), new FieldList());
$metadataForm->loadDataFrom($processedData[$filePostId]);
$metadataForm->saveInto($fileObject);
$fileObject->write();
@@ -399,9 +399,9 @@ function SyncForm() {
$form = new Form(
$this,
'SyncForm',
- new FieldSet(
+ new FieldList(
),
- new FieldSet(
+ new FieldList(
$btn = new FormAction('doSync', _t('FILESYSTEMSYNC','Look for new files'))
)
);
View
20 code/controllers/CMSMain.php
@@ -160,7 +160,7 @@ function SearchForm() {
create_function('$a,$b', 'return ($a == "CMSSiteTreeFilter_Search") ? 1 : -1;')
);
- $fields = new FieldSet(
+ $fields = new FieldList(
new TextField('Term', _t('CMSSearch.FILTERLABELTEXT', 'Content')),
$dateGroup = new FieldGroup(
$dateFrom = new DateField('LastEditedFrom', _t('CMSSearch.FILTERDATEFROM', 'From')),
@@ -185,7 +185,7 @@ function SearchForm() {
$dateFrom->setConfig('showcalendar', true);
$dateTo->setConfig('showcalendar', true);
- $actions = new FieldSet(
+ $actions = new FieldList(
$resetAction = new ResetFormAction('clear', _t('CMSMain_left.ss.CLEAR', 'Clear')),
$searchAction = new FormAction('doSearch', _t('CMSMain_left.ss.SEARCH', 'Search'))
);
@@ -397,7 +397,7 @@ public function getRecord($id, $versionID = null) {
/**
* @param Int $id
- * @param FieldSet $fields
+ * @param FieldList $fields
* @return Form
*/
public function getEditForm($id = null, $fields = null) {
@@ -476,8 +476,8 @@ public function getEditForm($id = null, $fields = null) {
} if ($id == 0 || $id == 'root') {
return $this->RootForm();
} else if($id) {
- return new Form($this, "EditForm", new FieldSet(
- new LabelField('PageDoesntExistLabel',_t('CMSMain.PAGENOTEXISTS',"This page doesn't exist"))), new FieldSet()
+ return new Form($this, "EditForm", new FieldList(
+ new LabelField('PageDoesntExistLabel',_t('CMSMain.PAGENOTEXISTS',"This page doesn't exist"))), new FieldList()
);
}
}
@@ -852,12 +852,12 @@ function SideReportsForm() {
$form = new Form(
$this,
'SideReportsForm',
- new FieldSet(
+ new FieldList(
$selectorField,
new HiddenField('ID', false, ($record) ? $record->ID : null),
new HiddenField('Locale', false, $this->Locale)
),
- new FieldSet(
+ new FieldList(
new FormAction('doShowSideReport', _t('CMSMain_left.ss.GO','Go'))
)
);
@@ -1037,7 +1037,7 @@ function AddForm() {
}
$labelTriangle = '<span class="label-triangle"></span>';
- $fields = new FieldSet(
+ $fields = new FieldList(
// new HiddenField("ParentID", false, ($this->parentRecord) ? $this->parentRecord->ID : null),
// TODO Should be part of the form attribute, but not possible in current form API
$hintsField = new LiteralField('Hints', sprintf('<span class="hints" data-hints="%s"></span>', $this->SiteTreeHints())),
@@ -1053,7 +1053,7 @@ function AddForm() {
$parentField->setValue(($record) ? $record->ID : null);
- $actions = new FieldSet(
+ $actions = new FieldList(
// $resetAction = new ResetFormAction('doCancel', _t('CMSMain.Cancel', 'Cancel')),
$createAction = new FormAction("doAdd", _t('CMSMain.Create',"Create"))
);
@@ -1138,7 +1138,7 @@ function publishall($request) {
} else {
$token = SecurityToken::inst();
- $fields = new FieldSet();
+ $fields = new FieldList();
$token->updateFieldSet($fields);
$tokenField = $fields->First();
$tokenHtml = ($tokenField) ? $tokenField->FieldHolder() : '';
View
8 code/controllers/CMSPageHistoryController.php
@@ -82,7 +82,7 @@ function getEditForm($id = null, $fields = null, $versionID = null, $compareID =
$form = parent::getEditForm($record, ($record) ? $record->getCMSFields() : null);
- $form->setActions(new FieldSet(
+ $form->setActions(new FieldList(
$revert = new FormAction('doRollback', _t('CMSPageHistoryController.REVERTTOTHISVERSION', 'Revert to this version'))
));
@@ -193,7 +193,7 @@ function VersionsForm() {
$form = new Form(
$this,
'VersionsForm',
- new FieldSet(
+ new FieldList(
new CheckboxField(
'ShowUnpublished',
_t('CMSPageHistoryController.SHOWUNPUBLISHED','Show unpublished versions'),
@@ -207,7 +207,7 @@ function VersionsForm() {
new LiteralField('VersionsHtml', $versionsHtml),
$hiddenID = new HiddenField('ID', false, "")
),
- new FieldSet(
+ new FieldList(
new FormAction(
'doCompare', _t('CMSPageHistoryController.COMPAREVERSIONS','Compare Versions')
),
@@ -408,7 +408,7 @@ function CompareVersionsForm($versionID, $otherVersionID) {
if($record) {
$form = $this->getEditForm($id, null, null, true);
- $form->setActions(new FieldSet());
+ $form->setActions(new FieldList());
$form->addExtraClass('compare');
// Comparison views shouldn't be editable.
View
4 code/controllers/StaticExporter.php
@@ -39,10 +39,10 @@ function index() {
}
function StaticExportForm() {
- return new Form($this, 'StaticExportForm', new FieldSet(
+ return new Form($this, 'StaticExportForm', new FieldList(
// new TextField('folder', _t('StaticExporter.FOLDEREXPORT','Folder to export to')),
new TextField('baseurl', _t('StaticExporter.BASEURL','Base URL'))
- ), new FieldSet(
+ ), new FieldList(
new FormAction('export', _t('StaticExporter.EXPORTTO','Export to that folder'))
));
}
View
2 code/forms/AssetTableField.php
@@ -164,7 +164,7 @@ function getCustomFieldsFor($childData) {
$urlLink .= "<span class='readonly'><a href='{$childData->Link()}'>{$childData->RelativeLink()}</a></span>";
$urlLink .= "</div>";
- $detailFormFields = new FieldSet(
+ $detailFormFields = new FieldList(
new TabSet("BottomRoot",
$mainTab = new Tab('Main',
new TextField("Title", _t('AssetTableField.TITLE','Title')),
View
4 code/forms/FolderUnusedAssetsField.php
@@ -8,15 +8,15 @@ class Folder_UnusedAssetsField extends CompositeField {
public function __construct($folder) {
$this->folder = $folder;
- parent::__construct(new FieldSet());
+ parent::__construct(new FieldList());
}
public function getChildren() {
if($this->children->Count() == 0) {
$inlineFormAction = new InlineFormAction("delete_unused_thumbnails", _t('Folder.DELETEUNUSEDTHUMBNAILS', 'Delete unused thumbnails'));
$inlineFormAction->includeDefaultJS(false) ;
- $this->children = new FieldSet(
+ $this->children = new FieldList(
new LiteralField( "UnusedAssets", "<h2>"._t('Folder.UNUSEDFILESTITLE', 'Unused files')."</h2>" ),
$this->getAssetList(),
new FieldGroup(
View
6 code/model/SiteConfig.php
@@ -44,7 +44,7 @@ public static function disable_theme($theme) {
function getCMSFields() {
Requirements::javascript(CMS_DIR . "/javascript/SitetreeAccess.js");
- $fields = new FieldSet(
+ $fields = new FieldList(
new TabSet("Root",
$tabMain = new Tab('Main',
$titleField = new TextField("Title", _t('SiteConfig.SITETITLE', "Site title")),
@@ -128,11 +128,11 @@ public function getAvailableThemes($baseDir = null) {
*/
function getCMSActions() {
if (Permission::check('ADMIN') || Permission::check('EDIT_SITECONFIG')) {
- $actions = new FieldSet(
+ $actions = new FieldList(
new FormAction('save_siteconfig', _t('CMSMain.SAVE','Save'))
);
} else {
- $actions = new FieldSet();
+ $actions = new FieldList();
}
$this->extend('updateCMSActions', $actions);
View
16 code/model/SiteTree.php
@@ -1736,16 +1736,16 @@ function VirtualPages() {
}
/**
- * Returns a FieldSet with which to create the main editing form.
+ * Returns a FieldList with which to create the main editing form.
*
* You can override this in your child classes to add extra fields - first
* get the parent fields using parent::getCMSFields(), then use
- * addFieldToTab() on the FieldSet.
+ * addFieldToTab() on the FieldList.
*
* See {@link getSettingsFields()} for a different set of fields
* concerned with configuration aspects on the record, e.g. access control
*
- * @return FieldSet The fields to be displayed in the CMS.
+ * @return FieldList The fields to be displayed in the CMS.
*/
function getCMSFields() {
require_once("forms/Form.php");
@@ -1827,7 +1827,7 @@ function getCMSFields() {
$url = (strlen($baseLink) > 36) ? "..." .substr($baseLink, -32) : $baseLink;
$urlHelper = sprintf("<span>%s</span>", $url);
- $fields = new FieldSet(
+ $fields = new FieldList(
$rootTab = new TabSet("Root",
$tabMain = new Tab('Main',
new TextField("Title", $this->fieldLabel('Title')),
@@ -1878,10 +1878,10 @@ function getCMSFields() {
* Returns fields related to configuration aspects on this record, e.g. access control.
* See {@link getCMSFields()} for content-related fields.
*
- * @return FieldSet
+ * @return FieldList
*/
function getSettingsFields() {
- $fields = new FieldSet(
+ $fields = new FieldList(
$rootTab = new TabSet("Root",
$tabBehaviour = new Tab('Settings',
new DropdownField(
@@ -2028,10 +2028,10 @@ function fieldLabels($includerelations = true) {
/**
* Get the actions available in the CMS for this page - eg Save, Publish.
- * @return FieldSet The available actions for this page.
+ * @return FieldList The available actions for this page.
*/
function getCMSActions() {
- $actions = new FieldSet();
+ $actions = new FieldList();
// "readonly"/viewing version that isn't the current version of the record
$stageOrLiveRecord = Versioned::get_one_by_stage($this->class, Versioned::current_stage(), sprintf('"SiteTree"."ID" = %d', $this->ID));
View
2 code/reports/BrokenLinksReport.php
@@ -104,7 +104,7 @@ function columns() {
return $fields;
}
function parameterFields() {
- return new FieldSet(
+ return new FieldList(
new DropdownField('CheckSite', _t('BrokenLinksReport.CheckSite','Check site'), array(
'Published' => _t('BrokenLinksReport.CheckSiteDropdownPublished', 'Published Site'),
'Draft' => _t('BrokenLinksReport.CheckSiteDropdownDraft', 'Draft Site')
View
14 code/reports/Report.php
@@ -11,7 +11,7 @@
* {@link description()}: Return the description - i18n is your responsibility
* {@link sourceQuery()}: Return a DataObjectSet of the search results
* {@link columns()}: Return information about the columns in this report.
- * {@link parameterFields()}: Return a FieldSet of the fields that can be used to filter this
+ * {@link parameterFields()}: Return a FieldList of the fields that can be used to filter this
* report.
*
* If you can't express your report as a query, you can implement the this method instead:
@@ -29,7 +29,7 @@
*
* {@link getReportField()}: Return a FormField in the place where your report's TableListField
* usually appears.
- * {@link getCMSFields()}: Return the FieldSet representing the complete right-hand area of the
+ * {@link getCMSFields()}: Return the FieldList representing the complete right-hand area of the
* report, including the title, description, parameter fields, and results.
*
* Showing reports to the user
@@ -94,7 +94,7 @@ function description() {
}
/**
- * Return a FieldSet specifying the search criteria for this report.
+ * Return a FieldList specifying the search criteria for this report.
*
* Override this method to define search criteria.
*/
@@ -158,17 +158,17 @@ function dataClass() {
/**
- * Returns a FieldSet with which to create the CMS editing form.
+ * Returns a FieldList with which to create the CMS editing form.
* You can use the extend() method of FieldSet to create customised forms for your other
* data objects.
*
* @uses getReportField() to render a table, or similar field for the report. This
* method should be defined on the SS_Report subclasses.
*
- * @return FieldSet
+ * @return FieldList
*/
function getCMSFields() {
- $fields = new FieldSet(
+ $fields = new FieldList(
new LiteralField(
'ReportTitle',
"<h3>{$this->title()}</h3>"
@@ -200,7 +200,7 @@ function getCMSFields() {
function getCMSActions() {
// getCMSActions() can be extended with updateCMSActions() on a extension
- $actions = new FieldSet();
+ $actions = new FieldList();
$this->extend('updateCMSActions', $actions);
return $actions;
}
View
8 code/reports/SideReport.php
@@ -211,7 +211,7 @@ function columns() {
);
}
function getParameterFields() {
- return new FieldSet(
+ return new FieldList(
new CheckboxField('OnLive', _t('SideReport.ParameterLiveCheckbox', 'Check live site'))
);
}
@@ -250,7 +250,7 @@ function columns() {
}
function getParameterFields() {
- return new FieldSet(
+ return new FieldList(
new CheckboxField('OnLive', _t('SideReport.ParameterLiveCheckbox', 'Check live site'))
);
}
@@ -284,7 +284,7 @@ function columns() {
}
function getParameterFields() {
- return new FieldSet(
+ return new FieldList(
new CheckboxField('OnLive', _t('SideReport.ParameterLiveCheckbox', 'Check live site'))
);
}
@@ -319,7 +319,7 @@ function columns() {
}
function getParameterFields() {
- return new FieldSet(
+ return new FieldList(
new CheckboxField('OnLive', _t('SideReport.ParameterLiveCheckbox', 'Check live site'))
);
}
View
4 code/search/AdvancedSearchForm.php
@@ -11,7 +11,7 @@ class AdvancedSearchForm extends SearchForm {
*/
function __construct($controller, $name, $fields = null, $actions = null) {
if(!$fields) {
- $fields = new FieldSet(
+ $fields = new FieldList(
$searchBy = new CompositeField(
new HeaderField('SearchByHeader',_t('AdvancedSearchForm.SEARCHBY', 'SEARCH BY')),
new TextField("+", _t('AdvancedSearchForm.ALLWORDS', 'All Words')),
@@ -44,7 +44,7 @@ function __construct($controller, $name, $fields = null, $actions = null) {
}
if(!$actions) {
- $actions = new FieldSet(
+ $actions = new FieldList(
new FormAction("results", _t('AdvancedSearchForm.GO', 'Go'))
);
}
View
4 code/search/ContentControllerSearchExtension.php
@@ -21,10 +21,10 @@ function SearchForm() {
$searchText = $this->owner->request->getVar('Search');
}
- $fields = new FieldSet(
+ $fields = new FieldList(
new TextField('Search', false, $searchText)
);
- $actions = new FieldSet(
+ $actions = new FieldList(
new FormAction('results', _t('SearchForm.GO', 'Go'))
);
$form = new SearchForm($this->owner, 'SearchForm', $fields, $actions);
View
8 code/search/SearchForm.php
@@ -31,13 +31,13 @@ class SearchForm extends Form {
*
* @param Controller $controller
* @param string $name The name of the form (used in URL addressing)
- * @param FieldSet $fields Optional, defaults to a single field named "Search". Search logic needs to be customized
+ * @param FieldList $fields Optional, defaults to a single field named "Search". Search logic needs to be customized
* if fields are added to the form.
- * @param FieldSet $actions Optional, defaults to a single field named "Go".
+ * @param FieldList $actions Optional, defaults to a single field named "Go".
*/
function __construct($controller, $name, $fields = null, $actions = null) {
if(!$fields) {
- $fields = new FieldSet(
+ $fields = new FieldList(
new TextField('Search', _t('SearchForm.SEARCH', 'Search')
));
}
@@ -47,7 +47,7 @@ function __construct($controller, $name, $fields = null, $actions = null) {
}
if(!$actions) {
- $actions = new FieldSet(
+ $actions = new FieldList(
new FormAction("getResults", _t('SearchForm.GO', 'Go'))
);
}
View
2 code/widgets/Widget.php
@@ -35,7 +35,7 @@ class Widget extends DataObject {
static $description = "Description of what this widget does.";
function getCMSFields() {
- $fields = new FieldSet();
+ $fields = new FieldList();
$this->extend('updateCMSFields', $fields);
return $fields;
}
View
4 tasks/RemoveOrphanedPagesTask.php
@@ -69,7 +69,7 @@ function index() {
}
function Form() {
- $fields = new FieldSet();
+ $fields = new FieldList();
$source = array();
$fields->push(new HeaderField(
@@ -167,7 +167,7 @@ function Form() {
$this,
'Form',
$fields,
- new FieldSet(
+ new FieldList(
new FormAction('doSubmit', _t('RemoveOrphanedPagesTask.BUTTONRUN', 'Run'))
)
);
View
2 tests/controller/CMSMainTest.php
@@ -113,7 +113,7 @@ function testThatGetCMSFieldsWorksOnEveryPageType() {
$page->flushCache();
$page = DataObject::get_by_id("SiteTree", $page->ID);
- $this->assertTrue($page->getCMSFields(null) instanceof FieldSet);
+ $this->assertTrue($page->getCMSFields(null) instanceof FieldList);
}
}
View
2 tests/widgets/WidgetAreaEditorTest.php
@@ -461,7 +461,7 @@ class WidgetAreaEditorTest_TestWidget extends Widget implements TestOnly {
'Title' => 'Varchar'
);
public function getCMSFields() {
- $fields = new FieldSet();
+ $fields = new FieldList();
$fields->push(new TextField('Title'));
return $fields;
}
View
4 tests/widgets/WidgetControllerTest.php
@@ -68,10 +68,10 @@ function Form() {
$widgetform = new Form(
$this,
'Form',
- new FieldSet(
+ new FieldList(
new TextField('TestValue')
),
- new FieldSet(
+ new FieldList(
new FormAction('doAction')
)
);

0 comments on commit 05e9083

Please sign in to comment.
Something went wrong with that request. Please try again.