API CHANGE Switch usage from FieldSet to FieldList

This commit is contained in:
Stig Lindqvist 2011-10-26 18:35:51 +13:00 committed by Stig Lindqvist
parent 49866b25a2
commit 05e90838c0
19 changed files with 62 additions and 62 deletions

View File

@ -135,7 +135,7 @@ JS
* 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 @@ JS
<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 @@ JS
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 @@ JS
$form = new Form(
$this,
'SyncForm',
new FieldSet(
new FieldList(
),
new FieldSet(
new FieldList(
$btn = new FormAction('doSync', _t('FILESYSTEMSYNC','Look for new files'))
)
);

View File

@ -160,7 +160,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
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 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
$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 @@ JS;
/**
* @param Int $id
* @param FieldSet $fields
* @param FieldList $fields
* @return Form
*/
public function getEditForm($id = null, $fields = null) {
@ -476,8 +476,8 @@ JS;
} 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 @@ JS;
$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 @@ JS;
}
$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 @@ JS;
$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 @@ JS;
} else {
$token = SecurityToken::inst();
$fields = new FieldSet();
$fields = new FieldList();
$token->updateFieldSet($fields);
$tokenField = $fields->First();
$tokenHtml = ($tokenField) ? $tokenField->FieldHolder() : '';

View File

@ -82,7 +82,7 @@ class CMSPageHistoryController extends CMSMain {
$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 @@ class CMSPageHistoryController extends CMSMain {
$form = new Form(
$this,
'VersionsForm',
new FieldSet(
new FieldList(
new CheckboxField(
'ShowUnpublished',
_t('CMSPageHistoryController.SHOWUNPUBLISHED','Show unpublished versions'),
@ -207,7 +207,7 @@ class CMSPageHistoryController extends CMSMain {
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 @@ class CMSPageHistoryController extends CMSMain {
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 File

@ -39,10 +39,10 @@ class StaticExporter extends Controller {
}
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 File

@ -164,7 +164,7 @@ class AssetTableField extends ComplexTableField {
$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 File

@ -8,7 +8,7 @@ class Folder_UnusedAssetsField extends CompositeField {
public function __construct($folder) {
$this->folder = $folder;
parent::__construct(new FieldSet());
parent::__construct(new FieldList());
}
public function getChildren() {
@ -16,7 +16,7 @@ class Folder_UnusedAssetsField extends CompositeField {
$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 File

@ -44,7 +44,7 @@ class SiteConfig extends DataObject implements PermissionProvider {
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 @@ class SiteConfig extends DataObject implements PermissionProvider {
*/
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 File

@ -1736,16 +1736,16 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
}
/**
* 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 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
$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 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
* 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 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
/**
* 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 File

@ -104,7 +104,7 @@ class BrokenLinksReport extends SS_Report {
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 File

@ -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 @@ class SS_Report extends ViewableData {
}
/**
* 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 @@ class SS_Report extends ViewableData {
/**
* 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 @@ class SS_Report extends ViewableData {
function getCMSActions() {
// getCMSActions() can be extended with updateCMSActions() on a extension
$actions = new FieldSet();
$actions = new FieldList();
$this->extend('updateCMSActions', $actions);
return $actions;
}

View File

@ -211,7 +211,7 @@ class SideReport_BrokenLinks extends SS_Report {
);
}
function getParameterFields() {
return new FieldSet(
return new FieldList(
new CheckboxField('OnLive', _t('SideReport.ParameterLiveCheckbox', 'Check live site'))
);
}
@ -250,7 +250,7 @@ class SideReport_BrokenFiles extends SS_Report {
}
function getParameterFields() {
return new FieldSet(
return new FieldList(
new CheckboxField('OnLive', _t('SideReport.ParameterLiveCheckbox', 'Check live site'))
);
}
@ -284,7 +284,7 @@ class SideReport_BrokenVirtualPages extends SS_Report {
}
function getParameterFields() {
return new FieldSet(
return new FieldList(
new CheckboxField('OnLive', _t('SideReport.ParameterLiveCheckbox', 'Check live site'))
);
}
@ -319,7 +319,7 @@ class SideReport_BrokenRedirectorPages extends SS_Report {
}
function getParameterFields() {
return new FieldSet(
return new FieldList(
new CheckboxField('OnLive', _t('SideReport.ParameterLiveCheckbox', 'Check live site'))
);
}

View File

@ -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 @@ class AdvancedSearchForm extends SearchForm {
}
if(!$actions) {
$actions = new FieldSet(
$actions = new FieldList(
new FormAction("results", _t('AdvancedSearchForm.GO', 'Go'))
);
}

View File

@ -21,10 +21,10 @@ class ContentControllerSearchExtension extends Extension {
$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 File

@ -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 @@ class SearchForm extends Form {
}
if(!$actions) {
$actions = new FieldSet(
$actions = new FieldList(
new FormAction("getResults", _t('SearchForm.GO', 'Go'))
);
}

View File

@ -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 File

@ -69,7 +69,7 @@ in the other stage:<br />
}
function Form() {
$fields = new FieldSet();
$fields = new FieldList();
$source = array();
$fields->push(new HeaderField(
@ -167,7 +167,7 @@ in the other stage:<br />
$this,
'Form',
$fields,
new FieldSet(
new FieldList(
new FormAction('doSubmit', _t('RemoveOrphanedPagesTask.BUTTONRUN', 'Run'))
)
);

View File

@ -113,7 +113,7 @@ class CMSMainTest extends FunctionalTest {
$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 File

@ -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 File

@ -68,10 +68,10 @@ class WidgetControllerTest_Widget_Controller extends Widget_Controller implement
$widgetform = new Form(
$this,
'Form',
new FieldSet(
new FieldList(
new TextField('TestValue')
),
new FieldSet(
new FieldList(
new FormAction('doAction')
)
);