API CHANGE: Deprecated CompositeField->FieldSet() in favour of CompositeField->FieldList().

MINOR: Replaced usage of FieldSet with FieldList.
MINOR: Renamed FieldSetTest to FieldListTest.
This commit is contained in:
ajshort 2011-05-11 17:51:54 +10:00
parent def001566c
commit 1f6f7f0862
47 changed files with 291 additions and 284 deletions

View File

@ -35,7 +35,7 @@ class GroupImportForm extends Form {
$importSpec = $importer->getImportSpec();
$helpHtml = sprintf($helpHtml, implode(', ', array_keys($importSpec['fields'])));
$fields = new FieldSet(
$fields = new FieldList(
new LiteralField('Help', $helpHtml),
$fileField = new FileField(
'CsvFile',
@ -48,7 +48,7 @@ class GroupImportForm extends Form {
$fileField->getValidator()->setAllowedExtensions(array('csv'));
}
if(!$actions) $actions = new FieldSet(
if(!$actions) $actions = new FieldList(
new FormAction('doImport', _t('SecurityAdmin_MemberImportForm.BtnImport', 'Import'))
);

View File

@ -746,7 +746,7 @@ class LeftAndMain extends Controller {
* Calls {@link SiteTree->getCMSFields()}
*
* @param Int $id
* @param FieldSet $fields
* @param FieldList $fields
* @return Form
*/
public function getEditForm($id = null, $fields = null) {
@ -847,7 +847,7 @@ class LeftAndMain extends Controller {
$form = new Form(
$this,
"EditForm",
new FieldSet(
new FieldList(
// new HeaderField(
// 'WelcomeHeader',
// $this->getApplicationName()
@ -861,7 +861,7 @@ class LeftAndMain extends Controller {
// )
// )
),
new FieldSet()
new FieldList()
);
$form->unsetValidator();
$form->addExtraClass('cms-edit-form');
@ -881,10 +881,10 @@ class LeftAndMain extends Controller {
$form = new Form(
$this,
'AddForm',
new FieldSet(
new FieldList(
new HiddenField('ParentID')
),
new FieldSet(
new FieldList(
$addAction = new FormAction('doAdd', _t('AssetAdmin_left.ss.GO','Go'))
)
);
@ -949,7 +949,7 @@ class LeftAndMain extends Controller {
$form = new Form(
$this,
'BatchActionsForm',
new FieldSet(
new FieldList(
new HiddenField('csvIDs'),
new DropdownField(
'Action',
@ -957,7 +957,7 @@ class LeftAndMain extends Controller {
$actionsMap
)
),
new FieldSet(
new FieldList(
// TODO i18n
new FormAction('submit', "Go")
)

View File

@ -34,7 +34,7 @@ class MemberImportForm extends Form {
$importSpec = $importer->getImportSpec();
$helpHtml = sprintf($helpHtml, implode(', ', array_keys($importSpec['fields'])));
$fields = new FieldSet(
$fields = new FieldList(
new LiteralField('Help', $helpHtml),
$fileField = new FileField(
'CsvFile',
@ -47,7 +47,7 @@ class MemberImportForm extends Form {
$fileField->getValidator()->setAllowedExtensions(array('csv'));
}
if(!$actions) $actions = new FieldSet(
if(!$actions) $actions = new FieldList(
new FormAction('doImport', _t('SecurityAdmin_MemberImportForm.BtnImport', 'Import'))
);

View File

@ -228,7 +228,7 @@ class MemberTableField extends ComplexTableField {
* Add existing member to group by name (with JS-autocompletion)
*/
function AddRecordForm() {
$fields = new FieldSet();
$fields = new FieldList();
foreach($this->FieldList() as $fieldName => $fieldTitle) {
// If we're adding the set password field, we want to hide the text from any peeping eyes
if($fieldName == 'SetPassword') {
@ -240,7 +240,7 @@ class MemberTableField extends ComplexTableField {
if($this->group) {
$fields->push(new HiddenField('ctf[ID]', null, $this->group->ID));
}
$actions = new FieldSet(
$actions = new FieldList(
new FormAction('addtogroup', _t('MemberTableField.ADD','Add'))
);

View File

@ -402,7 +402,7 @@ class ModelAdmin_CollectionController extends Controller {
$form = new Form($this, "SearchForm",
$fields,
new FieldSet(
new FieldList(
new FormAction('search', _t('MemberTableField.SEARCH', 'Search')),
$clearAction = new ResetFormAction('clearsearch', _t('ModelAdmin.CLEAR_SEARCH','Clear Search'))
),
@ -434,8 +434,8 @@ class ModelAdmin_CollectionController extends Controller {
$buttonLabel = sprintf(_t('ModelAdmin.CREATEBUTTON', "Create '%s'", PR_MEDIUM, "Create a new instance from a model class"), singleton($modelName)->i18n_singular_name());
$form = new Form($this, "CreateForm",
new FieldSet(),
new FieldSet($createButton = new FormAction('add', $buttonLabel)),
new FieldList(),
new FieldList($createButton = new FormAction('add', $buttonLabel)),
$validator = new RequiredFields()
);
$createButton->addExtraClass('ss-ui-action-constructive');
@ -467,7 +467,7 @@ class ModelAdmin_CollectionController extends Controller {
if(!singleton($modelName)->canCreate(Member::currentUser())) return false;
$fields = new FieldSet(
$fields = new FieldList(
new HiddenField('ClassName', _t('ModelAdmin.CLASSTYPE'), $modelName),
new FileField('_CsvFile', false)
);
@ -493,7 +493,7 @@ class ModelAdmin_CollectionController extends Controller {
$fields->push(new LiteralField("SpecFor{$modelName}", $specHTML));
$fields->push(new CheckboxField('EmptyBeforeImport', 'Clear Database before import', false));
$actions = new FieldSet(
$actions = new FieldList(
new FormAction('import', _t('ModelAdmin.IMPORT', 'Import from CSV'))
);
@ -766,11 +766,11 @@ class ModelAdmin_CollectionController extends Controller {
$form = new Form(
$this,
'ResultsForm',
new FieldSet(
new FieldList(
new HeaderField('SearchResults', _t('ModelAdmin.SEARCHRESULTS','Search Results'), 2),
$tf
),
new FieldSet()
new FieldList()
);
// Include the search criteria on the results form URL, but not dodgy variables like those below
@ -839,7 +839,7 @@ class ModelAdmin_CollectionController extends Controller {
if(!$validator) $validator = new RequiredFields();
$validator->setJavascriptValidationHandler('none');
$actions = new FieldSet (
$actions = new FieldList (
new FormAction("doCreate", _t('ModelAdmin.ADDBUTTON', "Add"))
);
@ -1030,7 +1030,7 @@ class ModelAdmin_RecordController extends Controller {
*/
public function ViewForm() {
$fields = $this->currentRecord->getCMSFields();
$form = new Form($this, "EditForm", $fields, new FieldSet());
$form = new Form($this, "EditForm", $fields, new FieldList());
$form->loadDataFrom($this->currentRecord);
$form->makeReadonly();
return $form;

View File

@ -110,7 +110,7 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
// unset 'inlineadd' permission, we don't want inline addition
$memberList->setPermissions(array('edit', 'delete', 'add'));
$fields = new FieldSet(
$fields = new FieldList(
new TabSet(
'Root',
new Tab('Members', singleton('Member')->i18n_plural_name(),
@ -155,7 +155,7 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
$rolesTab->push($rolesCTF);
}
$actions = new FieldSet(
$actions = new FieldList(
new FormAction('addmember',_t('SecurityAdmin.ADDMEMBER','Add Member'))
);

View File

@ -116,8 +116,8 @@ class MemberTableFieldTest_Controller extends Controller implements TestOnly {
return new Form(
$this,
'FormNoGroup',
new FieldSet(new MemberTableField($this, "Members", $group1)),
new FieldSet(new FormAction('submit'))
new FieldList(new MemberTableField($this, "Members", $group1)),
new FieldList(new FormAction('submit'))
);
}
@ -131,8 +131,8 @@ class MemberTableFieldTest_Controller extends Controller implements TestOnly {
return new Form(
$this,
'FormNoGroup',
new FieldSet(new MemberTableField($this, "Members")),
new FieldSet(new FormAction('submit'))
new FieldList(new MemberTableField($this, "Members")),
new FieldList(new FormAction('submit'))
);
}

View File

@ -779,7 +779,7 @@ class File extends DataObject {
* @return FieldSet
*/
function uploadMetadataFields() {
$fields = new FieldSet();
$fields = new FieldList();
$fields->push(new TextField('Title', $this->fieldLabel('Title')));
$this->extend('updateUploadMetadataFields', $fields);

View File

@ -386,7 +386,7 @@ class Folder extends File {
/**
* Return the FieldSet used to edit this folder in the CMS.
* You can modify this fieldset by subclassing folder, or by creating a {@link DataExtension}
* and implemeting updateCMSFields(FieldSet $fields) on that extension.
* and implemeting updateCMSFields(FieldList $fields) on that extension.
*/
function getCMSFields() {
$fileList = new AssetTableField(
@ -407,7 +407,7 @@ class Folder extends File {
$deleteButton = new HiddenField('deletemarked');
}
$fields = new FieldSet(
$fields = new FieldList(
new HiddenField("Name"),
new TabSet("Root",
new Tab("Files", _t('Folder.FILESTAB', "Files"),

View File

@ -189,7 +189,7 @@ class ComplexTableField extends TableListField {
* @param string $name
* @param string $sourceClass
* @param array $fieldList
* @param FieldSet $detailFormFields
* @param FieldList $detailFormFields
* @param string $sourceFilter
* @param string $sourceSort
* @param string $sourceJoin
@ -331,7 +331,7 @@ JS;
* @return FieldSet
*/
function createFieldSet() {
$fieldset = new FieldSet();
$fieldset = new FieldList();
foreach($this->fieldTypes as $key => $fieldType){
$fieldset->push(new $fieldType($key));
}
@ -813,7 +813,7 @@ class ComplexTableField_Popup extends Form {
Requirements::clear();
Requirements::unblock_all();
$actions = new FieldSet();
$actions = new FieldList();
if(!$readonly) {
$actions->push(
$saveAction = new FormAction(

View File

@ -9,7 +9,7 @@
class CompositeField extends FormField {
/**
* @var FieldSet
* @var FieldList
*/
protected $children;
@ -29,13 +29,13 @@ class CompositeField extends FormField {
protected $columnCount = null;
public function __construct($children = null) {
if($children instanceof FieldSet) {
if($children instanceof FieldList) {
$this->children = $children;
} elseif(is_array($children)) {
$this->children = new FieldSet($children);
$this->children = new FieldList($children);
} else {
$children = is_array(func_get_args()) ? func_get_args() : array();
$this->children = new FieldSet($children);
$this->children = new FieldList($children);
}
$this->children->setContainerField($this);
@ -46,12 +46,19 @@ class CompositeField extends FormField {
}
/**
* Returns all the sub-fields, suitable for <% control FieldSet %>
* Returns all the sub-fields, suitable for <% control FieldList %>
*/
public function FieldSet() {
public function FieldList() {
return $this->children;
}
/**
* @deprecated 3.0 Please use {@link FieldList()}.
*/
public function FieldSet() {
return $this->FieldList();
}
public function setID($id) {
$this->id = $id;
}
@ -62,14 +69,14 @@ class CompositeField extends FormField {
/**
* Accessor method for $this->children
* @return FieldSet
* @return FieldList
*/
public function getChildren() {
return $this->children;
}
/**
* @param FieldSet $children
* @param FieldList $children
*/
public function setChildren($children) {
$this->children = $children;
@ -79,7 +86,7 @@ class CompositeField extends FormField {
* Returns the fields nested inside another DIV
*/
function FieldHolder() {
$fs = $this->FieldSet();
$fs = $this->FieldList();
$idAtt = isset($this->id) ? " id=\"{$this->id}\"" : '';
$className = ($this->columnCount) ? "field CompositeField {$this->extraClass()} multicolumn" : "field CompositeField {$this->extraClass()}";
$content = "<div class=\"$className\"$idAtt>\n";
@ -102,7 +109,7 @@ class CompositeField extends FormField {
* Returns the fields in the restricted field holder inside a DIV.
*/
function SmallFieldHolder() {//return $this->FieldHolder();
$fs = $this->FieldSet();
$fs = $this->FieldList();
$idAtt = isset($this->id) ? " id=\"{$this->id}\"" : '';
$className = ($this->columnCount) ? "field CompositeField {$this->extraClass()} multicolumn" : "field CompositeField {$this->extraClass()}";
$content = "<div class=\"$className\"$idAtt>";
@ -168,7 +175,7 @@ class CompositeField extends FormField {
}
/**
* @uses FieldSet->insertBefore()
* @uses FieldList->insertBefore()
*/
public function insertBefore($field, $insertBefore) {
$ret = $this->children->insertBefore($field, $insertBefore);
@ -209,7 +216,7 @@ class CompositeField extends FormField {
* versions of all the children
*/
public function performReadonlyTransformation() {
$newChildren = new FieldSet();
$newChildren = new FieldList();
$clone = clone $this;
foreach($clone->getChildren() as $idx => $child) {
if(is_object($child)) $child = $child->transform(new ReadonlyTransformation());
@ -226,7 +233,7 @@ class CompositeField extends FormField {
* versions of all the children
*/
public function performDisabledTransformation($trans) {
$newChildren = new FieldSet();
$newChildren = new FieldList();
$clone = clone $this;
if($clone->getChildren()) foreach($clone->getChildren() as $idx => $child) {
if(is_object($child)) {

View File

@ -69,7 +69,7 @@ class ConfirmedPasswordField extends FormField {
*/
function __construct($name, $title = null, $value = "", $form = null, $showOnClick = false, $titleConfirmField = null) {
// naming with underscores to prevent values from actually being saved somewhere
$this->children = new FieldSet(
$this->children = new FieldList(
new PasswordField(
"{$name}[_Password]",
(isset($title)) ? $title : _t('Member.PASSWORD', 'Password')

View File

@ -441,7 +441,7 @@ class FieldList extends ArrayList {
*/
function transform($trans) {
$this->flushFieldsCache();
$newFields = new FieldSet();
$newFields = new FieldList();
foreach($this as $field) {
$newFields->push($field->transform($trans));
}

View File

@ -17,11 +17,11 @@
* class ExampleForm_Controller extends Page_Controller {
*
* public function Form() {
* $fields = new FieldSet(
* $fields = new FieldList(
* new TextField('MyName'),
* new FileField('MyFile')
* );
* $actions = new FieldSet(
* $actions = new FieldList(
* new FormAction('doUpload', 'Upload file')
* );
* $validator = new RequiredFields(array('MyName', 'MyFile'));

View File

@ -137,7 +137,7 @@ class FileIFrameField extends FileField {
$fileSources["existing//$selectFile"] = new TreeDropdownField('ExistingFile', '', 'File');
$fields = new FieldSet (
$fields = new FieldList (
new HeaderField('EditFileHeader', $title),
new SelectionGroup('FileSource', $fileSources)
);
@ -151,7 +151,7 @@ class FileIFrameField extends FileField {
$this,
'EditFileForm',
$fields,
new FieldSet(
new FieldList(
new FormAction('save', $title)
)
);
@ -223,10 +223,10 @@ class FileIFrameField extends FileField {
$form = new Form (
$this,
'DeleteFileForm',
new FieldSet (
new FieldList (
new HiddenField('DeleteFile', null, false)
),
new FieldSet (
new FieldList (
$deleteButton = new FormAction (
'delete', sprintf(_t('FileIFrameField.DELETE', 'Delete %s'), $this->FileTypeName())
)

View File

@ -142,15 +142,15 @@ class Form extends RequestHandler {
*
* @param Controller $controller The parent controller, necessary to create the appropriate form action tag.
* @param String $name The method on the controller that will return this form object.
* @param FieldSet $fields All of the fields in the form - a {@link FieldSet} of {@link FormField} objects.
* @param FieldSet $actions All of the action buttons in the form - a {@link FieldSet} of {@link FormAction} objects
* @param FieldList $fields All of the fields in the form - a {@link FieldSet} of {@link FormField} objects.
* @param FieldList $actions All of the action buttons in the form - a {@link FieldSet} of {@link FormAction} objects
* @param Validator $validator Override the default validator instance (Default: {@link RequiredFields})
*/
function __construct($controller, $name, FieldSet $fields, FieldSet $actions, $validator = null) {
function __construct($controller, $name, FieldList $fields, FieldList $actions, $validator = null) {
parent::__construct();
if(!$fields instanceof FieldSet) throw new InvalidArgumentException('$fields must be a valid FieldSet instance');
if(!$actions instanceof FieldSet) throw new InvalidArgumentException('$fields must be a valid FieldSet instance');
if(!$fields instanceof FieldList) throw new InvalidArgumentException('$fields must be a valid FieldList instance');
if(!$actions instanceof FieldList) throw new InvalidArgumentException('$fields must be a valid FieldList instance');
if($validator && !$validator instanceof Validator) throw new InvalidArgumentException('$validator must be a Valdidator instance');
$fields->setForm($this);
@ -398,13 +398,13 @@ class Form extends RequestHandler {
}
function transform(FormTransformation $trans) {
$newFields = new FieldSet();
$newFields = new FieldList();
foreach($this->fields as $field) {
$newFields->push($field->transform($trans));
}
$this->fields = $newFields;
$newActions = new FieldSet();
$newActions = new FieldList();
foreach($this->actions as $action) {
$newActions->push($action->transform($trans));
}
@ -445,7 +445,7 @@ class Form extends RequestHandler {
* Convert this form to another format.
*/
function transformTo(FormTransformation $format) {
$newFields = new FieldSet();
$newFields = new FieldList();
foreach($this->fields as $field) {
$newFields->push($field->transformTo($format));
}
@ -463,7 +463,7 @@ class Form extends RequestHandler {
* @return FieldSet
*/
public function getExtraFields() {
$extraFields = new FieldSet();
$extraFields = new FieldList();
$token = $this->getSecurityToken();
$tokenField = $token->updateFieldSet($this->fields);
@ -507,7 +507,7 @@ class Form extends RequestHandler {
/**
* Setter for the form fields.
*
* @param FieldSet $fields
* @param FieldList $fields
*/
function setFields($fields) {
$this->fields = $fields;
@ -540,7 +540,7 @@ class Form extends RequestHandler {
/**
* Setter for the form actions.
*
* @param FieldSet $actions
* @param FieldList $actions
*/
function setActions($actions) {
$this->actions = $actions;
@ -550,7 +550,7 @@ class Form extends RequestHandler {
* Unset all form actions
*/
function unsetAllActions(){
$this->actions = new FieldSet();
$this->actions = new FieldList();
}
/**

View File

@ -653,7 +653,7 @@ HTML;
/**
* Set the fieldset that contains this field.
*
* @param FieldSet $containerFieldSet
* @param FieldList $containerFieldSet
*/
function setContainerFieldSet($containerFieldSet) {
$this->containerFieldSet = $containerFieldSet;

View File

@ -65,7 +65,7 @@ class FormScaffolder extends Object {
* @return FieldSet
*/
public function getFieldSet() {
$fields = new FieldSet();
$fields = new FieldList();
// tabbed or untabbed
if($this->tabbed) {

View File

@ -235,7 +235,7 @@ class HtmlEditorField_Toolbar extends RequestHandler {
$form = new Form(
$this->controller,
"{$this->name}/LinkForm",
new FieldSet(
new FieldList(
new LiteralField(
'Heading',
sprintf('<h3>%s</h3>', _t('HtmlEditorField.LINK', 'Link'))
@ -263,7 +263,7 @@ class HtmlEditorField_Toolbar extends RequestHandler {
new HiddenField('Locale', null, $this->controller->Locale)
)
),
new FieldSet(
new FieldList(
new FormAction('insert', _t('HtmlEditorField.BUTTONINSERTLINK', 'Insert link')),
new FormAction('remove', _t('HtmlEditorField.BUTTONREMOVELINK', 'Remove link'))
)
@ -291,7 +291,7 @@ class HtmlEditorField_Toolbar extends RequestHandler {
throw new Exception('ThumbnailStripField class required for HtmlEditorField->ImageForm()');
}
$fields = new FieldSet(
$fields = new FieldList(
new LiteralField(
'Heading',
sprintf('<h3>%s</h3>', _t('HtmlEditorField.IMAGE', 'Image'))
@ -299,7 +299,7 @@ class HtmlEditorField_Toolbar extends RequestHandler {
$contentComposite = new CompositeField(
new TreeDropdownField('FolderID', _t('HtmlEditorField.FOLDER', 'Folder'), 'Folder'),
new CompositeField(new FieldSet(
new CompositeField(new FieldList(
new LiteralField('ShowUpload', '<p class="showUploadField"><a href="#">'. _t('HtmlEditorField.SHOWUPLOADFORM', 'Upload File') .'</a></p>'),
new FileField("Files[0]" , _t('AssetAdmin.CHOOSEFILE','Choose file: ')),
new LiteralField('Response', '<div id="UploadFormResponse"></div>'),
@ -327,7 +327,7 @@ class HtmlEditorField_Toolbar extends RequestHandler {
)
);
$actions = new FieldSet(
$actions = new FieldList(
new FormAction('insertimage', _t('HtmlEditorField.BUTTONINSERTIMAGE', 'Insert image'))
);
@ -359,7 +359,7 @@ class HtmlEditorField_Toolbar extends RequestHandler {
$form = new Form(
$this->controller,
"{$this->name}/FlashForm",
new FieldSet(
new FieldList(
new LiteralField(
'Heading',
sprintf('<h3>%s</h3>', _t('HtmlEditorField.FLASH', 'Flash'))
@ -374,7 +374,7 @@ class HtmlEditorField_Toolbar extends RequestHandler {
)
)
),
new FieldSet(
new FieldList(
new FormAction("insertflash", _t('HtmlEditorField.BUTTONINSERTFLASH', 'Insert Flash'))
)
);

View File

@ -34,7 +34,7 @@
* $map = $myDoSet->toDropDownMap();
*
* // Instantiate the OptionsetField
* $fieldset = new Fieldset(
* $fieldset = new FieldList(
* new OptionsetField(
* $name = "Foobar",
* $title = "FooBar's optionset",

View File

@ -16,7 +16,7 @@ class ScaffoldingComplexTableField_Popup extends ComplexTableField_Popup {
Requirements::clear();
$actions = new FieldSet();
$actions = new FieldList();
if(!$readonly) {
$actions->push(
$saveAction = new FormAction("saveComplexTableField", "Save")

View File

@ -42,7 +42,7 @@ class SelectionGroup extends CompositeField {
$newChildren[$idx] = $child;
}
$clone->setChildren(new FieldSet($newChildren));
$clone->setChildren(new FieldList($newChildren));
$clone->setReadonly(true);
return $clone;
}

View File

@ -32,12 +32,12 @@
*
* <code>
* function Form() {
* return new Form($this, "Form", new FieldSet(
* return new Form($this, "Form", new FieldList(
* new SimpleImageField (
* $name = "FileTypeID",
* $title = "Upload your FileType"
* )
* ), new FieldSet(
* ), new FieldList(
*
* // List the action buttons here - doform executes the function 'doform' below
* new FormAction("doform", "Submit")

View File

@ -217,7 +217,7 @@ class TableField extends TableListField {
$this,
null,
$this->FieldSetForRow(),
new FieldSet()
new FieldList()
);
$form->loadDataFrom($dataObj);
@ -281,7 +281,7 @@ class TableField extends TableListField {
* @return FieldSet
*/
function FieldSetForRow() {
$fieldset = new FieldSet();
$fieldset = new FieldList();
if($this->fieldTypes){
foreach($this->fieldTypes as $key => $fieldType) {
if(isset($fieldType->class) && is_subclass_of($fieldType, 'FormField')) {
@ -360,7 +360,7 @@ class TableField extends TableListField {
}
}
$form = new Form($this, null, $fieldset, new FieldSet());
$form = new Form($this, null, $fieldset, new FieldList());
foreach ($dataObjects as $objectid => $fieldValues) {
// 'new' counts as an empty column, don't save it
@ -592,7 +592,7 @@ JS;
class TableField_Item extends TableListField_Item {
/**
* @var FieldSet $fields
* @var FieldList $fields
*/
protected $fields;
@ -719,7 +719,7 @@ class TableField_Item extends TableListField_Item {
$i++;
}
}
return new FieldSet($this->fields);
return new FieldList($this->fields);
}
function Fields() {

View File

@ -160,11 +160,11 @@ abstract class DataExtension extends Extension {
* should just be used to add or modify tabs, or fields which
* are specific to the CMS-context.
*
* Caution: Use {@link FieldSet->addFieldToTab()} to add fields.
* Caution: Use {@link FieldList->addFieldToTab()} to add fields.
*
* @param FieldSet $fields FieldSet with a contained TabSet
* @param FieldList $fields FieldSet with a contained TabSet
*/
function updateCMSFields(FieldSet &$fields) {
function updateCMSFields(FieldList $fields) {
}
/**
@ -173,18 +173,18 @@ abstract class DataExtension extends Extension {
*
* Caution: Use {@link FieldSet->push()} to add fields.
*
* @param FieldSet $fields FieldSet without TabSet nesting
* @param FieldList $fields FieldSet without TabSet nesting
*/
function updateFrontEndFields(FieldSet &$fields) {
function updateFrontEndFields(FieldList $fields) {
}
/**
* This is used to provide modifications to the form actions
* used in the CMS. {@link DataObject->getCMSActions()}.
*
* @param FieldSet $actions FieldSet
* @param FieldList $actions FieldSet
*/
function updateCMSActions(FieldSet &$actions) {
function updateCMSActions(FieldList $actions) {
}
/**

View File

@ -1782,7 +1782,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
),
(array)$_params
);
$fields = new FieldSet();
$fields = new FieldList();
foreach($this->searchableFields() as $fieldName => $spec) {
if($params['restrictFields'] && !in_array($fieldName, $params['restrictFields'])) continue;
@ -1899,7 +1899,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
* @return an Empty FieldSet(); need to be overload by solid subclass
*/
public function getCMSActions() {
$actions = new FieldSet();
$actions = new FieldList();
$this->extend('updateCMSActions', $actions);
return $actions;
}

View File

@ -63,14 +63,14 @@ class SearchContext extends Object {
*
* @param string $modelClass The base {@link DataObject} class that search properties related to.
* Also used to generate a set of result objects based on this class.
* @param FieldSet $fields Optional. FormFields mapping to {@link DataObject::$db} properties
* @param FieldList $fields Optional. FormFields mapping to {@link DataObject::$db} properties
* which are to be searched. Derived from modelclass using
* {@link DataObject::scaffoldSearchFields()} if left blank.
* @param array $filters Optional. Derived from modelclass if left blank
*/
function __construct($modelClass, $fields = null, $filters = null) {
$this->modelClass = $modelClass;
$this->fields = ($fields) ? $fields : new FieldSet();
$this->fields = ($fields) ? $fields : new FieldList();
$this->filters = ($filters) ? $filters : array();
parent::__construct();
@ -241,7 +241,7 @@ class SearchContext extends Object {
/**
* Apply a list of searchable fields to the current search context.
*
* @param FieldSet $fields
* @param FieldList $fields
*/
public function setFields($fields) {
$this->fields = $fields;

View File

@ -27,7 +27,7 @@ class ChangePasswordForm extends Form {
}
if(!$fields) {
$fields = new FieldSet();
$fields = new FieldList();
// Security/changepassword?h=XXX redirects to Security/changepassword
// without GET parameter to avoid potential HTTP referer leakage.
@ -40,7 +40,7 @@ class ChangePasswordForm extends Form {
$fields->push(new PasswordField("NewPassword2", _t('Member.CONFIRMNEWPASSWORD', "Confirm New Password")));
}
if(!$actions) {
$actions = new FieldSet(
$actions = new FieldList(
new FormAction("doChangePassword", _t('Member.BUTTONCHANGEPASSWORD', "Change Password"))
);
}

View File

@ -62,7 +62,7 @@ class Group extends DataObject {
public function getCMSFields() {
Requirements::javascript(SAPPHIRE_DIR . '/javascript/PermissionCheckboxSetField.js');
$fields = new FieldSet(
$fields = new FieldList(
new TabSet("Root",
new Tab('Members', _t('SecurityAdmin.MEMBERS', 'Members'),
new TextField("Title", $this->fieldLabel('Title')),

View File

@ -1570,7 +1570,7 @@ class Member_ProfileForm extends Form {
$fields = $member->getCMSFields();
$fields->push(new HiddenField('ID','ID',$member->ID));
$actions = new FieldSet(
$actions = new FieldList(
new FormAction('dosave',_t('CMSMain.SAVE', 'Save'))
);

View File

@ -50,16 +50,16 @@ class MemberLoginForm extends LoginForm {
}
if($checkCurrentUser && Member::currentUser() && Member::logged_in_session_exists()) {
$fields = new FieldSet(
$fields = new FieldList(
new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this)
);
$actions = new FieldSet(
$actions = new FieldList(
new FormAction("logout", _t('Member.BUTTONLOGINOTHER', "Log in as someone else"))
);
} else {
if(!$fields) {
$label=singleton('Member')->fieldLabel(Member::get_unique_identifier_field());
$fields = new FieldSet(
$fields = new FieldList(
new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this),
//Regardless of what the unique identifer field is (usually 'Email'), it will be held in the 'Email' value, below:
new TextField("Email", $label, Session::get('SessionForms.MemberLoginForm.Email'), null, $this),
@ -73,7 +73,7 @@ class MemberLoginForm extends LoginForm {
}
}
if(!$actions) {
$actions = new FieldSet(
$actions = new FieldList(
new FormAction('dologin', _t('Member.BUTTONLOGIN', "Log in")),
new LiteralField(
'forgotPassword',

View File

@ -470,10 +470,10 @@ class Security extends Controller {
return Object::create('MemberLoginForm',
$this,
'LostPasswordForm',
new FieldSet(
new FieldList(
new EmailField('Email', _t('Member.EMAIL', 'Email'))
),
new FieldSet(
new FieldList(
new FormAction(
'forgotPassword',
_t('Security.BUTTONSEND', 'Send me the password reset link')

View File

@ -164,7 +164,7 @@ class SecurityToken extends Object {
* on the returned {@link HiddenField}, you'll need to take
* care of this yourself.
*
* @param FieldSet $fieldset
* @param FieldList $fieldset
* @return HiddenField|false
*/
function updateFieldSet(&$fieldset) {
@ -234,7 +234,7 @@ class NullSecurityToken extends SecurityToken {
}
/**
* @param FieldSet $fieldset
* @param FieldList $fieldset
* @return false
*/
function updateFieldSet(&$fieldset) {

View File

@ -298,10 +298,10 @@ class RequestHandlingTest_Controller extends Controller implements TestOnly {
}
function TestForm() {
return new RequestHandlingTest_Form($this, "TestForm", new FieldSet(
return new RequestHandlingTest_Form($this, "TestForm", new FieldList(
new RequestHandlingTest_FormField("MyField"),
new RequestHandlingTest_SubclassedFormField("SubclassedField")
), new FieldSet(
), new FieldList(
new FormAction("myAction")
));
}
@ -350,10 +350,10 @@ class RequestHandlingTest_FormActionController extends Controller {
return new Form(
$this,
"Form",
new FieldSet(
new FieldList(
new TextField("MyField")
),
new FieldSet(
new FieldList(
new FormAction("formaction"),
new FormAction('formactionInAllowedActions')
)
@ -472,8 +472,8 @@ class RequestHandlingTest_ControllerFormWithAllowedActions extends Controller im
return new RequestHandlingTest_FormWithAllowedActions(
$this,
'Form',
new FieldSet(),
new FieldSet(
new FieldList(),
new FieldList(
new FormAction('allowedformaction'),
new FormAction('disallowedformaction') // disallowed through $allowed_actions in form
)

View File

@ -117,8 +117,8 @@ class CheckboxSetFieldTest extends SapphireTest {
$form = new Form(
new Controller(),
'Form',
new FieldSet($field),
new FieldSet()
new FieldList($field),
new FieldList()
);
$form->loadDataFrom($articleWithTags);
$this->assertEquals(

View File

@ -108,11 +108,11 @@ class ComplexTableFieldTest_Controller extends Controller {
$form = new Form(
$this,
'ManyManyForm',
new FieldSet(
new FieldList(
new HiddenField('ID', '', $team->ID),
$playersField
),
new FieldSet(
new FieldList(
new FormAction('doSubmit', 'Submit')
)
);
@ -137,11 +137,11 @@ class ComplexTableFieldTest_Controller extends Controller {
$form = new Form(
$this,
'HasManyForm',
new FieldSet(
new FieldList(
new HiddenField('ID', '', $team->ID),
$sponsorsField
),
new FieldSet(
new FieldList(
new FormAction('doSubmit', 'Submit')
)
);

View File

@ -22,10 +22,10 @@ class DatetimeFieldTest extends SapphireTest {
$form = new Form(
new Controller(),
'Form',
new FieldSet(
new FieldList(
$f = new DatetimeField('MyDatetime', null)
),
new FieldSet(
new FieldList(
new FormAction('doSubmit')
)
);

View File

@ -1,34 +1,34 @@
<?php
/**
* Tests for FieldSet
* Tests for FieldList
*
* @package sapphire
* @subpackage tests
*
* @todo test for {@link FieldSet->setValues()}. Need to check
* @todo test for {@link FieldList->setValues()}. Need to check
* that the values that were set are the correct ones given back.
* @todo test for {@link FieldSet->transform()} and {@link FieldSet->makeReadonly()}.
* Need to ensure that it correctly transforms the FieldSet object.
* @todo test for {@link FieldSet->HiddenFields()}. Need to check
* @todo test for {@link FieldList->transform()} and {@link FieldList->makeReadonly()}.
* Need to ensure that it correctly transforms the FieldList object.
* @todo test for {@link FieldList->HiddenFields()}. Need to check
* the fields returned are the correct HiddenField objects for a
* given FieldSet instance.
* @todo test for {@link FieldSet->dataFields()}.
* @todo test for {@link FieldSet->findOrMakeTab()}.
* given FieldList instance.
* @todo test for {@link FieldList->dataFields()}.
* @todo test for {@link FieldList->findOrMakeTab()}.
* @todo the same as above with insertBefore() and insertAfter()
*
*/
class FieldSetTest extends SapphireTest {
class FieldListTest extends SapphireTest {
/**
* Test adding a field to a tab in a set.
*/
function testAddFieldToTab() {
$fields = new FieldSet();
$fields = new FieldList();
$tab = new Tab('Root');
$fields->push($tab);
/* We add field objects to the FieldSet, using two different methods */
/* We add field objects to the FieldList, using two different methods */
$fields->addFieldToTab('Root', new TextField('Country'));
$fields->addFieldsToTab('Root', array(
new EmailField('Email'),
@ -53,7 +53,7 @@ class FieldSetTest extends SapphireTest {
* Test removing a single field from a tab in a set.
*/
function testRemoveSingleFieldFromTab() {
$fields = new FieldSet();
$fields = new FieldList();
$tab = new Tab('Root');
$fields->push($tab);
@ -71,7 +71,7 @@ class FieldSetTest extends SapphireTest {
}
function testRemoveTab() {
$fields = new FieldSet(new TabSet(
$fields = new FieldList(new TabSet(
'Root',
$tab1 = new Tab('Tab1'),
$tab2 = new Tab('Tab2'),
@ -85,12 +85,12 @@ class FieldSetTest extends SapphireTest {
}
function testHasTabSet() {
$untabbedFields = new FieldSet(
$untabbedFields = new FieldList(
new TextField('Field1')
);
$this->assertFalse($untabbedFields->hasTabSet());
$tabbedFields = new FieldSet(
$tabbedFields = new FieldList(
new TabSet('Root',
new Tab('Tab1')
)
@ -102,7 +102,7 @@ class FieldSetTest extends SapphireTest {
* Test removing an array of fields from a tab in a set.
*/
function testRemoveMultipleFieldsFromTab() {
$fields = new FieldSet();
$fields = new FieldList();
$tab = new Tab('Root');
$fields->push($tab);
@ -131,9 +131,9 @@ class FieldSetTest extends SapphireTest {
* Test removing a field from a set by it's name.
*/
function testRemoveFieldByName() {
$fields = new FieldSet();
$fields = new FieldList();
/* First of all, we add a field into our FieldSet object */
/* First of all, we add a field into our FieldList object */
$fields->push(new TextField('Name', 'Your name'));
/* We have 1 field in our set now */
@ -150,7 +150,7 @@ class FieldSetTest extends SapphireTest {
* Test replacing a field with another one.
*/
function testReplaceField() {
$fields = new FieldSet();
$fields = new FieldList();
$tab = new Tab('Root');
$fields->push($tab);
@ -168,7 +168,7 @@ class FieldSetTest extends SapphireTest {
}
function testRenameField() {
$fields = new FieldSet();
$fields = new FieldList();
$nameField = new TextField('Name', 'Before title');
$fields->push($nameField);
@ -186,8 +186,8 @@ class FieldSetTest extends SapphireTest {
}
function testReplaceAFieldInADifferentTab() {
/* A FieldSet gets created with a TabSet and some field objects */
$fieldSet = new FieldSet(
/* A FieldList gets created with a TabSet and some field objects */
$FieldList = new FieldList(
new TabSet('Root', $main = new Tab('Main',
new TextField('A'),
new TextField('B')
@ -197,8 +197,8 @@ class FieldSetTest extends SapphireTest {
))
);
/* The field "A" gets added to the FieldSet we just created created */
$fieldSet->addFieldToTab('Root.Other', $newA = new TextField('A', 'New Title'));
/* The field "A" gets added to the FieldList we just created created */
$FieldList->addFieldToTab('Root.Other', $newA = new TextField('A', 'New Title'));
/* The field named "A" has been removed from the Main tab to make way for our new field named "A" in Other tab. */
$this->assertEquals(1, $main->Fields()->Count());
@ -209,7 +209,7 @@ class FieldSetTest extends SapphireTest {
* Test finding a field that's inside a tabset, within another tab.
*/
function testNestedTabsFindingFieldByName() {
$fields = new FieldSet();
$fields = new FieldList();
/* 2 tabs get created within a TabSet inside our set */
$tab = new TabSet('Root',
@ -241,7 +241,7 @@ class FieldSetTest extends SapphireTest {
}
function testTabTitles() {
$set = new FieldSet(
$set = new FieldList(
$rootTabSet = new TabSet('Root',
$tabSetWithoutTitle = new TabSet('TabSetWithoutTitle'),
$tabSetWithTitle = new TabSet('TabSetWithTitle', 'My TabSet Title',
@ -281,10 +281,10 @@ class FieldSetTest extends SapphireTest {
/**
* Test pushing a field to a set.
*
* This tests {@link FieldSet->push()}.
* This tests {@link FieldList->push()}.
*/
function testPushFieldToSet() {
$fields = new FieldSet();
$fields = new FieldList();
/* A field named Country is added to the set */
$fields->push(new TextField('Country'));
@ -310,10 +310,10 @@ class FieldSetTest extends SapphireTest {
/**
* Test inserting a field before another in a set.
*
* This tests {@link FieldSet->insertBefore()}.
* This tests {@link FieldList->insertBefore()}.
*/
function testInsertBeforeFieldToSet() {
$fields = new FieldSet();
$fields = new FieldList();
/* 3 fields are added to the set */
$fields->push(new TextField('Country'));
@ -337,7 +337,7 @@ class FieldSetTest extends SapphireTest {
}
function testInsertBeforeMultipleFields() {
$fields = new FieldSet(
$fields = new FieldList(
$root = new TabSet("Root",
$main = new Tab("Main",
$a = new TextField("A"),
@ -363,7 +363,7 @@ class FieldSetTest extends SapphireTest {
* Test inserting a field after another in a set.
*/
function testInsertAfterFieldToSet() {
$fields = new FieldSet();
$fields = new FieldList();
/* 3 fields are added to the set */
$fields->push(new TextField('Country'));
@ -379,16 +379,16 @@ class FieldSetTest extends SapphireTest {
/* The field we just added actually exists in the set */
$this->assertNotNull($fields->dataFieldByName('Title'));
/* We now have 4 fields in the FieldSet */
/* We now have 4 fields in the FieldList */
$this->assertEquals(4, $fields->Count());
/* The position of the Title field should be at number 2 */
$this->assertEquals('Title', $fields[1]->Name());
}
function testRootFieldSet() {
/* Given a nested set of FormField, CompositeField, and FieldSet objects */
$fieldSet = new FieldSet(
function testrootFieldSet() {
/* Given a nested set of FormField, CompositeField, and FieldList objects */
$FieldList = new FieldList(
$root = new TabSet("Root",
$main = new Tab("Main",
$a = new TextField("A"),
@ -397,27 +397,27 @@ class FieldSetTest extends SapphireTest {
)
);
/* rootFieldSet() should always evaluate to the same object: the topmost fieldset */
$this->assertSame($fieldSet, $fieldSet->rootFieldSet());
$this->assertSame($fieldSet, $root->rootFieldSet());
$this->assertSame($fieldSet, $main->rootFieldSet());
$this->assertSame($fieldSet, $a->rootFieldSet());
$this->assertSame($fieldSet, $b->rootFieldSet());
/* rootFieldSet() should always evaluate to the same object: the topmost FieldList */
$this->assertSame($FieldList, $FieldList->rootFieldSet());
$this->assertSame($FieldList, $root->rootFieldSet());
$this->assertSame($FieldList, $main->rootFieldSet());
$this->assertSame($FieldList, $a->rootFieldSet());
$this->assertSame($FieldList, $b->rootFieldSet());
/* If we push additional fields, they should also have the same rootFieldSet() */
$root->push($other = new Tab("Other"));
$other->push($c = new TextField("C"));
$root->push($third = new Tab("Third", $d = new TextField("D")));
$this->assertSame($fieldSet, $other->rootFieldSet());
$this->assertSame($fieldSet, $third->rootFieldSet());
$this->assertSame($fieldSet, $c->rootFieldSet());
$this->assertSame($fieldSet, $d->rootFieldSet());
$this->assertSame($FieldList, $other->rootFieldSet());
$this->assertSame($FieldList, $third->rootFieldSet());
$this->assertSame($FieldList, $c->rootFieldSet());
$this->assertSame($FieldList, $d->rootFieldSet());
}
function testAddingDuplicateReplacesOldField() {
/* Given a nested set of FormField, CompositeField, and FieldSet objects */
$fieldSet = new FieldSet(
/* Given a nested set of FormField, CompositeField, and FieldList objects */
$FieldList = new FieldList(
$root = new TabSet("Root",
$main = new Tab("Main",
$a = new TextField("A"),
@ -430,27 +430,27 @@ class FieldSetTest extends SapphireTest {
$newA = new TextField("A", "New A");
$newB = new TextField("B", "New B");
$fieldSet->addFieldToTab("Root.Main", $newA);
$fieldSet->addFieldToTab("Root.Other", $newB);
$FieldList->addFieldToTab("Root.Main", $newA);
$FieldList->addFieldToTab("Root.Other", $newB);
$this->assertSame($newA, $fieldSet->dataFieldByName("A"));
$this->assertSame($newB, $fieldSet->dataFieldByName("B"));
$this->assertSame($newA, $FieldList->dataFieldByName("A"));
$this->assertSame($newB, $FieldList->dataFieldByName("B"));
$this->assertEquals(1, $main->Fields()->Count());
/* Pushing fields on the end of the field set should remove them from the tab */
$thirdA = new TextField("A", "Third A");
$thirdB = new TextField("B", "Third B");
$fieldSet->push($thirdA);
$fieldSet->push($thirdB);
$FieldList->push($thirdA);
$FieldList->push($thirdB);
$this->assertSame($thirdA, $fieldSet->fieldByName("A"));
$this->assertSame($thirdB, $fieldSet->fieldByName("B"));
$this->assertSame($thirdA, $FieldList->fieldByName("A"));
$this->assertSame($thirdB, $FieldList->fieldByName("B"));
$this->assertEquals(0, $main->Fields()->Count());
}
function testAddingFieldToNonExistentTabCreatesThatTab() {
$fieldSet = new FieldSet(
$FieldList = new FieldList(
$root = new TabSet("Root",
$main = new Tab("Main",
$a = new TextField("A")
@ -459,13 +459,13 @@ class FieldSetTest extends SapphireTest {
);
/* Add a field to a non-existent tab, and it will be created */
$fieldSet->addFieldToTab("Root.Other", $b = new TextField("B"));
$this->assertNotNull($fieldSet->fieldByName('Root')->fieldByName('Other'));
$this->assertSame($b, $fieldSet->fieldByName('Root')->fieldByName('Other')->Fields()->First());
$FieldList->addFieldToTab("Root.Other", $b = new TextField("B"));
$this->assertNotNull($FieldList->fieldByName('Root')->fieldByName('Other'));
$this->assertSame($b, $FieldList->fieldByName('Root')->fieldByName('Other')->Fields()->First());
}
function testAddingFieldToATabWithTheSameNameAsTheField() {
$fieldSet = new FieldSet(
$FieldList = new FieldList(
$root = new TabSet("Root",
$main = new Tab("Main",
$a = new TextField("A")
@ -475,13 +475,13 @@ class FieldSetTest extends SapphireTest {
/* If you have a tab with the same name as the field, then technically it's a duplicate. However, it's allowed because
tab isn't a data field. Only duplicate data fields are problematic */
$fieldSet->addFieldToTab("Root.MyName", $myName = new TextField("MyName"));
$this->assertNotNull($fieldSet->fieldByName('Root')->fieldByName('MyName'));
$this->assertSame($myName, $fieldSet->fieldByName('Root')->fieldByName('MyName')->Fields()->First());
$FieldList->addFieldToTab("Root.MyName", $myName = new TextField("MyName"));
$this->assertNotNull($FieldList->fieldByName('Root')->fieldByName('MyName'));
$this->assertSame($myName, $FieldList->fieldByName('Root')->fieldByName('MyName')->Fields()->First());
}
function testInsertBeforeWithNestedCompositeFields() {
$fieldSet = new FieldSet(
$FieldList = new FieldList(
new TextField('A_pre'),
new TextField('A'),
new TextField('A_post'),
@ -497,34 +497,34 @@ class FieldSetTest extends SapphireTest {
)
);
$fieldSet->insertBefore(
$FieldList->insertBefore(
$A_insertbefore = new TextField('A_insertbefore'),
'A'
);
$this->assertSame(
$A_insertbefore,
$fieldSet->dataFieldByName('A_insertbefore'),
'Field on toplevel fieldset can be inserted'
$FieldList->dataFieldByName('A_insertbefore'),
'Field on toplevel FieldList can be inserted'
);
$fieldSet->insertBefore(
$FieldList->insertBefore(
$B_insertbefore = new TextField('B_insertbefore'),
'B'
);
$this->assertSame(
$fieldSet->dataFieldByName('B_insertbefore'),
$FieldList->dataFieldByName('B_insertbefore'),
$B_insertbefore,
'Field on one nesting level fieldset can be inserted'
'Field on one nesting level FieldList can be inserted'
);
$fieldSet->insertBefore(
$FieldList->insertBefore(
$C_insertbefore = new TextField('C_insertbefore'),
'C'
);
$this->assertSame(
$fieldSet->dataFieldByName('C_insertbefore'),
$FieldList->dataFieldByName('C_insertbefore'),
$C_insertbefore,
'Field on two nesting levels fieldset can be inserted'
'Field on two nesting levels FieldList can be inserted'
);
}
@ -532,7 +532,7 @@ class FieldSetTest extends SapphireTest {
* @todo check actual placement of fields
*/
function testInsertBeforeWithNestedTabsets() {
$fieldSetA = new FieldSet(
$FieldListA = new FieldList(
$tabSetA = new TabSet('TabSet_A',
$tabA1 = new Tab('Tab_A1',
new TextField('A_pre'),
@ -549,7 +549,7 @@ class FieldSetTest extends SapphireTest {
'A'
);
$this->assertEquals(
$fieldSetA->dataFieldByName('A_insertbefore'),
$FieldListA->dataFieldByName('A_insertbefore'),
$A_insertbefore,
'Field on toplevel tab can be inserted'
);
@ -559,7 +559,7 @@ class FieldSetTest extends SapphireTest {
$this->assertEquals(2, $tabA1->fieldPosition('A'));
$this->assertEquals(3, $tabA1->fieldPosition('A_post'));
$fieldSetB = new FieldSet(
$FieldListB = new FieldList(
new TabSet('TabSet_A',
$tabsetB = new TabSet('TabSet_B',
$tabB1 = new Tab('Tab_B1',
@ -573,12 +573,12 @@ class FieldSetTest extends SapphireTest {
)
)
);
$fieldSetB->insertBefore(
$FieldListB->insertBefore(
$B_insertbefore = new TextField('B_insertbefore'),
'B'
);
$this->assertSame(
$fieldSetB->dataFieldByName('B_insertbefore'),
$FieldListB->dataFieldByName('B_insertbefore'),
$B_insertbefore,
'Field on nested tab can be inserted'
);
@ -589,7 +589,7 @@ class FieldSetTest extends SapphireTest {
}
function testInsertAfterWithNestedCompositeFields() {
$fieldSet = new FieldSet(
$FieldList = new FieldList(
new TextField('A_pre'),
new TextField('A'),
new TextField('A_post'),
@ -605,34 +605,34 @@ class FieldSetTest extends SapphireTest {
)
);
$fieldSet->insertAfter(
$FieldList->insertAfter(
$A_insertafter = new TextField('A_insertafter'),
'A'
);
$this->assertSame(
$A_insertafter,
$fieldSet->dataFieldByName('A_insertafter'),
'Field on toplevel fieldset can be inserted after'
$FieldList->dataFieldByName('A_insertafter'),
'Field on toplevel FieldList can be inserted after'
);
$fieldSet->insertAfter(
$FieldList->insertAfter(
$B_insertafter = new TextField('B_insertafter'),
'B'
);
$this->assertSame(
$fieldSet->dataFieldByName('B_insertafter'),
$FieldList->dataFieldByName('B_insertafter'),
$B_insertafter,
'Field on one nesting level fieldset can be inserted after'
'Field on one nesting level FieldList can be inserted after'
);
$fieldSet->insertAfter(
$FieldList->insertAfter(
$C_insertafter = new TextField('C_insertafter'),
'C'
);
$this->assertSame(
$fieldSet->dataFieldByName('C_insertafter'),
$FieldList->dataFieldByName('C_insertafter'),
$C_insertafter,
'Field on two nesting levels fieldset can be inserted after'
'Field on two nesting levels FieldList can be inserted after'
);
}
@ -640,7 +640,7 @@ class FieldSetTest extends SapphireTest {
* @todo check actual placement of fields
*/
function testInsertAfterWithNestedTabsets() {
$fieldSetA = new FieldSet(
$FieldListA = new FieldList(
$tabSetA = new TabSet('TabSet_A',
$tabA1 = new Tab('Tab_A1',
new TextField('A_pre'),
@ -657,7 +657,7 @@ class FieldSetTest extends SapphireTest {
'A'
);
$this->assertEquals(
$fieldSetA->dataFieldByName('A_insertafter'),
$FieldListA->dataFieldByName('A_insertafter'),
$A_insertafter,
'Field on toplevel tab can be inserted after'
);
@ -666,7 +666,7 @@ class FieldSetTest extends SapphireTest {
$this->assertEquals(2, $tabA1->fieldPosition('A_insertafter'));
$this->assertEquals(3, $tabA1->fieldPosition('A_post'));
$fieldSetB = new FieldSet(
$FieldListB = new FieldList(
new TabSet('TabSet_A',
$tabsetB = new TabSet('TabSet_B',
$tabB1 = new Tab('Tab_B1',
@ -680,12 +680,12 @@ class FieldSetTest extends SapphireTest {
)
)
);
$fieldSetB->insertAfter(
$FieldListB->insertAfter(
$B_insertafter = new TextField('B_insertafter'),
'B'
);
$this->assertSame(
$fieldSetB->dataFieldByName('B_insertafter'),
$FieldListB->dataFieldByName('B_insertafter'),
$B_insertafter,
'Field on nested tab can be inserted after'
);
@ -696,7 +696,7 @@ class FieldSetTest extends SapphireTest {
}
function testFieldPosition() {
$set = new FieldSet(
$set = new FieldList(
new TextField('A'),
new TextField('B'),
new TextField('C')
@ -716,17 +716,17 @@ class FieldSetTest extends SapphireTest {
}
function testMakeFieldReadonly() {
$fieldSet = new FieldSet(
$FieldList = new FieldList(
new TabSet('Root', new Tab('Main',
new TextField('A'),
new TextField('B')
)
));
$fieldSet->makeFieldReadonly('A');
$FieldList->makeFieldReadonly('A');
$this->assertTrue(
$fieldSet->dataFieldByName('A')->isReadonly(),
'Field nested inside a TabSet and FieldSet can be marked readonly by FieldSet->makeFieldReadonly()'
$FieldList->dataFieldByName('A')->isReadonly(),
'Field nested inside a TabSet and FieldList can be marked readonly by FieldList->makeFieldReadonly()'
);
}
}

View File

@ -12,10 +12,10 @@ class FileFieldTest extends FunctionalTest {
$form = new Form(
new Controller(),
'Form',
new FieldSet(
new FieldList(
$fileField = new FileField('cv', 'Upload your CV')
),
new FieldSet()
new FieldList()
);
$fileFieldValue = array(
'name' => 'aCV.txt',
@ -38,10 +38,10 @@ class FileFieldTest extends FunctionalTest {
$form = new Form(
new Controller(),
'Form',
new FieldSet(
new FieldList(
$fileField = new FileField('cv', 'Upload your CV')
),
new FieldSet(),
new FieldList(),
new RequiredFields('cv')
);
// All fields are filled but for some reason an error occured when uploading the file => fails

View File

@ -20,7 +20,7 @@ class FormScaffolderTest extends SapphireTest {
function testGetCMSFieldsSingleton() {
$fields = singleton('FormScaffolderTest_Article')->getCMSFields();
$form = new Form(new Controller(), 'TestForm', $fields, new FieldSet());
$form = new Form(new Controller(), 'TestForm', $fields, new FieldList());
$form->loadDataFrom(singleton('FormScaffolderTest_Article'));
$this->assertTrue($fields->hasTabSet(), 'getCMSFields() produces a TabSet');
@ -34,7 +34,7 @@ class FormScaffolderTest extends SapphireTest {
$article1 = $this->objFromFixture('FormScaffolderTest_Article', 'article1');
$fields = $article1->getCMSFields();
$form = new Form(new Controller(), 'TestForm', $fields, new FieldSet());
$form = new Form(new Controller(), 'TestForm', $fields, new FieldList());
$form->loadDataFrom($article1);
$this->assertNotNull($fields->dataFieldByName('AuthorID'), 'getCMSFields() includes has_one fields on instances');
@ -45,7 +45,7 @@ class FormScaffolderTest extends SapphireTest {
$article1 = $this->objFromFixture('FormScaffolderTest_Article', 'article1');
$fields = $article1->getCMSFields();
$form = new Form(new Controller(), 'TestForm', $fields, new FieldSet());
$form = new Form(new Controller(), 'TestForm', $fields, new FieldList());
$form->loadDataFrom($article1);
$this->assertNotNull(
@ -60,7 +60,7 @@ class FormScaffolderTest extends SapphireTest {
$fields = $article1->scaffoldFormFields(array(
'restrictFields' => array('Title')
));
$form = new Form(new Controller(), 'TestForm', $fields, new FieldSet());
$form = new Form(new Controller(), 'TestForm', $fields, new FieldList());
$form->loadDataFrom($article1);
$this->assertNotNull($fields->dataFieldByName('Title'), 'scaffoldCMSFields() includes explitly defined "restrictFields"');
@ -73,7 +73,7 @@ class FormScaffolderTest extends SapphireTest {
$fields = $article1->scaffoldFormFields(array(
'fieldClasses' => array('Title' => 'HtmlEditorField')
));
$form = new Form(new Controller(), 'TestForm', $fields, new FieldSet());
$form = new Form(new Controller(), 'TestForm', $fields, new FieldList());
$form->loadDataFrom($article1);
$this->assertNotNull(
@ -88,7 +88,7 @@ class FormScaffolderTest extends SapphireTest {
function testGetFormFields() {
$fields = singleton('FormScaffolderTest_Article')->getFrontEndFields();
$form = new Form(new Controller(), 'TestForm', $fields, new FieldSet());
$form = new Form(new Controller(), 'TestForm', $fields, new FieldList());
$form->loadDataFrom(singleton('FormScaffolderTest_Article'));
$this->assertFalse($fields->hasTabSet(), 'getFrontEndFields() doesnt produce a TabSet by default');

View File

@ -16,13 +16,13 @@ class FormTest extends FunctionalTest {
$form = new Form(
new Controller(),
'Form',
new FieldSet(
new FieldList(
new TextField('key1'),
new TextField('namespace[key2]'),
new TextField('namespace[key3][key4]'),
new TextField('othernamespace[key5][key6][key7]')
),
new FieldSet()
new FieldList()
);
// url would be ?key1=val1&namespace[key2]=val2&namespace[key3][key4]=val4&othernamespace[key5][key6][key7]=val7
@ -56,11 +56,11 @@ class FormTest extends FunctionalTest {
$form = new Form(
new Controller(),
'Form',
new FieldSet(
new FieldList(
new TextField('key1'),
new TextField('key2')
),
new FieldSet()
new FieldList()
);
$form->loadDataFrom(array(
'key1' => 'save',
@ -81,14 +81,14 @@ class FormTest extends FunctionalTest {
$form = new Form(
new Controller(),
'Form',
new FieldSet(
new FieldList(
new HeaderField('MyPlayerHeader','My Player'),
new TextField('Name'), // appears in both Player and Team
new TextareaField('Biography'),
new DateField('Birthday'),
new NumericField('BirthdayYear') // dynamic property
),
new FieldSet()
new FieldList()
);
$captainWithDetails = $this->objFromFixture('FormTest_Player', 'captainWithDetails');
@ -122,7 +122,7 @@ class FormTest extends FunctionalTest {
$form = new Form(
new Controller(),
'Form',
new FieldSet(
new FieldList(
new HeaderField('MyPlayerHeader','My Player'),
new TextField('Name'), // appears in both Player and Team
new TextareaField('Biography'),
@ -131,7 +131,7 @@ class FormTest extends FunctionalTest {
$unrelatedField = new TextField('UnrelatedFormField')
//new CheckboxSetField('Teams') // relation editing
),
new FieldSet()
new FieldList()
);
$unrelatedField->setValue("random value");
@ -329,8 +329,8 @@ class FormTest extends FunctionalTest {
return new Form(
new Controller(),
'Form',
new FieldSet(new TextField('key1')),
new FieldSet()
new FieldList(new TextField('key1')),
new FieldList()
);
}
@ -383,12 +383,12 @@ class FormTest_Controller extends Controller implements TestOnly {
$form = new Form(
$this,
'Form',
new FieldSet(
new FieldList(
new EmailField('Email'),
new TextField('SomeRequiredField'),
new CheckboxSetField('Boxes', null, array('1'=>'one','2'=>'two'))
),
new FieldSet(
new FieldList(
new FormAction('doSubmit')
),
new RequiredFields(
@ -407,10 +407,10 @@ class FormTest_Controller extends Controller implements TestOnly {
$form = new Form(
$this,
'FormWithSecurityToken',
new FieldSet(
new FieldList(
new EmailField('Email')
),
new FieldSet(
new FieldList(
new FormAction('doSubmit')
)
);
@ -444,10 +444,10 @@ class FormTest_ControllerWithSecurityToken extends Controller implements TestOnl
$form = new Form(
$this,
'Form',
new FieldSet(
new FieldList(
new EmailField('Email')
),
new FieldSet(
new FieldList(
new FormAction('doSubmit')
)
);

View File

@ -45,7 +45,7 @@ class MemberDatetimeOptionsetFieldTest extends SapphireTest {
function testDateFormatDefaultCheckedInFormField() {
$field = $this->createDateFormatFieldForMember($this->objFromFixture('Member', 'noformatmember'));
$field->setForm(new Form(new MemberDatetimeOptionsetFieldTest_Controller(), 'Form', new FieldSet(), new FieldSet())); // fake form
$field->setForm(new Form(new MemberDatetimeOptionsetFieldTest_Controller(), 'Form', new FieldList(), new FieldList())); // fake form
$parser = new CSSContentParser($field->Field());
$xmlArr = $parser->getBySelector('#Form_Form_DateFormat_MM_dd_yyyy');
$this->assertEquals('checked', (string) $xmlArr[0]['checked']);
@ -53,7 +53,7 @@ class MemberDatetimeOptionsetFieldTest extends SapphireTest {
function testTimeFormatDefaultCheckedInFormField() {
$field = $this->createTimeFormatFieldForMember($this->objFromFixture('Member', 'noformatmember'));
$field->setForm(new Form(new MemberDatetimeOptionsetFieldTest_Controller(), 'Form', new FieldSet(), new FieldSet())); // fake form
$field->setForm(new Form(new MemberDatetimeOptionsetFieldTest_Controller(), 'Form', new FieldList(), new FieldList())); // fake form
$parser = new CSSContentParser($field->Field());
$xmlArr = $parser->getBySelector('#Form_Form_TimeFormat_hh_mm_a');
$this->assertEquals('checked', (string) $xmlArr[0]['checked']);
@ -63,7 +63,7 @@ class MemberDatetimeOptionsetFieldTest extends SapphireTest {
$member = $this->objFromFixture('Member', 'noformatmember');
$member->setField('DateFormat', 'MM/dd/yyyy');
$field = $this->createDateFormatFieldForMember($member);
$field->setForm(new Form(new MemberDatetimeOptionsetFieldTest_Controller(), 'Form', new FieldSet(), new FieldSet())); // fake form
$field->setForm(new Form(new MemberDatetimeOptionsetFieldTest_Controller(), 'Form', new FieldList(), new FieldList())); // fake form
$parser = new CSSContentParser($field->Field());
$xmlArr = $parser->getBySelector('#Form_Form_DateFormat_MM_dd_yyyy');
$this->assertEquals('checked', (string) $xmlArr[0]['checked']);
@ -73,7 +73,7 @@ class MemberDatetimeOptionsetFieldTest extends SapphireTest {
$member = $this->objFromFixture('Member', 'noformatmember');
$member->setField('DateFormat', 'dd MM yy');
$field = $this->createDateFormatFieldForMember($member);
$field->setForm(new Form(new MemberDatetimeOptionsetFieldTest_Controller(), 'Form', new FieldSet(), new FieldSet())); // fake form
$field->setForm(new Form(new MemberDatetimeOptionsetFieldTest_Controller(), 'Form', new FieldList(), new FieldList())); // fake form
$parser = new CSSContentParser($field->Field());
$xmlInputArr = $parser->getBySelector('.valCustom input');
$xmlPreview = $parser->getBySelector('.preview');

View File

@ -28,8 +28,8 @@ class TableFieldTest extends SapphireTest {
$form = new Form(
new TableFieldTest_Controller(),
"Form",
new FieldSet($tableField),
new FieldSet()
new FieldList($tableField),
new FieldList()
);
// Test Insert
@ -106,8 +106,8 @@ class TableFieldTest extends SapphireTest {
$form = new Form(
new TableFieldTest_Controller(),
"Form",
new FieldSet($tableField),
new FieldSet()
new FieldList($tableField),
new FieldList()
);
$this->assertEquals(2, $tableField->sourceItems()->Count());
@ -155,8 +155,8 @@ class TableFieldTest extends SapphireTest {
$form = new Form(
new TableFieldTest_Controller(),
"Form",
new FieldSet($tableField),
new FieldSet()
new FieldList($tableField),
new FieldList()
);
$this->assertContains($perm1->ID, $tableField->sourceItems()->column('ID'));
@ -185,7 +185,7 @@ class TableFieldTest extends SapphireTest {
);
// Test with auto relation setting
$form = new Form(new TableFieldTest_Controller(), "Form", new FieldSet($tf), new FieldSet());
$form = new Form(new TableFieldTest_Controller(), "Form", new FieldList($tf), new FieldList());
$form->loadDataFrom($o);
$tf->setValue(array(

View File

@ -17,9 +17,9 @@ class TableListFieldTest extends SapphireTest {
"E" => "Col E",
));
// A TableListField must be inside a form for its links to be generated
$form = new Form(new TableListFieldTest_TestController(), "TestForm", new FieldSet(
$form = new Form(new TableListFieldTest_TestController(), "TestForm", new FieldList(
$table
), new FieldSet());
), new FieldList());
$result = $table->FieldHolder();
@ -45,9 +45,9 @@ class TableListFieldTest extends SapphireTest {
"E" => "Col E",
));
// A TableListField must be inside a form for its links to be generated
$form = new Form(new TableListFieldTest_TestController(), "TestForm", new FieldSet(
$form = new Form(new TableListFieldTest_TestController(), "TestForm", new FieldList(
$table
), new FieldSet());
), new FieldList());
$items = $table->sourceItems();
$this->assertNotNull($items);
@ -78,9 +78,9 @@ class TableListFieldTest extends SapphireTest {
"E" => "Col E",
));
// A TableListField must be inside a form for its links to be generated
$form = new Form(new TableListFieldTest_TestController(), "TestForm", new FieldSet(
$form = new Form(new TableListFieldTest_TestController(), "TestForm", new FieldList(
$table
), new FieldSet());
), new FieldList());
$table->ShowPagination = true;
$table->PageSize = 2;
@ -111,9 +111,9 @@ class TableListFieldTest extends SapphireTest {
"E" => "Col E",
));
// A TableListField must be inside a form for its links to be generated
$form = new Form(new TableListFieldTest_TestController(), "TestForm", new FieldSet(
$form = new Form(new TableListFieldTest_TestController(), "TestForm", new FieldList(
$table
), new FieldSet());
), new FieldList());
$table->ShowPagination = true;
$table->PageSize = 2;
@ -182,9 +182,9 @@ class TableListFieldTest extends SapphireTest {
"B" => "Col B"
));
$form = new Form(new TableListFieldTest_TestController(), "TestForm", new FieldSet(
$form = new Form(new TableListFieldTest_TestController(), "TestForm", new FieldList(
$table
), new FieldSet());
), new FieldList());
$csvResponse = $table->export();
@ -219,7 +219,7 @@ class TableListFieldTest extends SapphireTest {
function testLink() {
// A TableListField must be inside a form for its links to be generated
$form = new Form(new TableListFieldTest_TestController(), "TestForm", new FieldSet(
$form = new Form(new TableListFieldTest_TestController(), "TestForm", new FieldList(
new TableListField("Tester", "TableListFieldTest_Obj", array(
"A" => "Col A",
"B" => "Col B",
@ -227,7 +227,7 @@ class TableListFieldTest extends SapphireTest {
"D" => "Col D",
"E" => "Col E",
))
), new FieldSet());
), new FieldList());
$table = $form->dataFieldByName('Tester');
$this->assertEquals(
@ -252,9 +252,9 @@ class TableListFieldTest extends SapphireTest {
"E" => "Col E",
));
// A TableListField must be inside a form for its links to be generated
$form = new Form(new TableListFieldTest_TestController(), "TestForm", new FieldSet(
$form = new Form(new TableListFieldTest_TestController(), "TestForm", new FieldList(
$table
), new FieldSet());
), new FieldList());
$table->ShowPagination = true;
$table->PageSize = 2;
@ -307,7 +307,7 @@ class TableListFieldTest extends SapphireTest {
$list = new ArrayList(array($one, $two, $three));
// A TableListField must be inside a form for its links to be generated
$form = new Form(new TableListFieldTest_TestController(), "TestForm", new FieldSet(
$form = new Form(new TableListFieldTest_TestController(), "TestForm", new FieldList(
new TableListField("Tester", $list, array(
"A" => "Col A",
"B" => "Col B",
@ -315,7 +315,7 @@ class TableListFieldTest extends SapphireTest {
"D" => "Col D",
"E" => "Col E",
))
), new FieldSet());
), new FieldList());
$table = $form->dataFieldByName('Tester');
$rendered = $table->FieldHolder();
@ -367,8 +367,8 @@ class TableListFieldTest_TestController extends Controller {
$table->disableSorting();
// A TableListField must be inside a form for its links to be generated
return new Form($this, "TestForm", new FieldSet(
return new Form($this, "TestForm", new FieldList(
$table
), new FieldSet());
), new FieldList());
}
}

View File

@ -85,7 +85,7 @@ class SearchContextTest extends SapphireTest {
$context = $company->getDefaultSearchContext();
$fields = $context->getFields();
$this->assertEquals(
new FieldSet(
new FieldList(
new TextField("Name", 'Name'),
new TextareaField("Industry", 'Industry'),
new NumericField("AnnualProfit", 'The Almighty Annual Profit')

View File

@ -129,7 +129,7 @@ class GroupTest_Member extends Member implements TestOnly {
function getCMSFields() {
$groups = DataObject::get('Group');
$groupsMap = ($groups) ? $groups->map() : false;
$fields = new FieldSet(
$fields = new FieldList(
new HiddenField('ID', 'ID'),
new CheckboxSetField(
'Groups',
@ -147,7 +147,7 @@ class GroupTest_MemberForm extends Form {
function __construct($controller, $name) {
$fields = singleton('GroupTest_Member')->getCMSFields();
$actions = new FieldSet(
$actions = new FieldList(
new FormAction('doSave','save')
);

View File

@ -106,7 +106,7 @@ class SecurityTokenTest extends SapphireTest {
}
function testUpdateFieldSet() {
$fs = new FieldSet();
$fs = new FieldList();
$t = new SecurityToken();
$t->updateFieldSet($fs);
$f = $fs->dataFieldByName($t->getName());
@ -117,7 +117,7 @@ class SecurityTokenTest extends SapphireTest {
}
function testUpdateFieldSetDoesntAddTwice() {
$fs = new FieldSet();
$fs = new FieldList();
$t = new SecurityToken();
$t->updateFieldSet($fs); // first
$t->updateFieldSet($fs); // second