mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-29 20:59:23 +02:00
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:
parent
def001566c
commit
1f6f7f0862
@ -35,7 +35,7 @@ class GroupImportForm extends Form {
|
|||||||
$importSpec = $importer->getImportSpec();
|
$importSpec = $importer->getImportSpec();
|
||||||
$helpHtml = sprintf($helpHtml, implode(', ', array_keys($importSpec['fields'])));
|
$helpHtml = sprintf($helpHtml, implode(', ', array_keys($importSpec['fields'])));
|
||||||
|
|
||||||
$fields = new FieldSet(
|
$fields = new FieldList(
|
||||||
new LiteralField('Help', $helpHtml),
|
new LiteralField('Help', $helpHtml),
|
||||||
$fileField = new FileField(
|
$fileField = new FileField(
|
||||||
'CsvFile',
|
'CsvFile',
|
||||||
@ -48,7 +48,7 @@ class GroupImportForm extends Form {
|
|||||||
$fileField->getValidator()->setAllowedExtensions(array('csv'));
|
$fileField->getValidator()->setAllowedExtensions(array('csv'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$actions) $actions = new FieldSet(
|
if(!$actions) $actions = new FieldList(
|
||||||
new FormAction('doImport', _t('SecurityAdmin_MemberImportForm.BtnImport', 'Import'))
|
new FormAction('doImport', _t('SecurityAdmin_MemberImportForm.BtnImport', 'Import'))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -746,7 +746,7 @@ class LeftAndMain extends Controller {
|
|||||||
* Calls {@link SiteTree->getCMSFields()}
|
* Calls {@link SiteTree->getCMSFields()}
|
||||||
*
|
*
|
||||||
* @param Int $id
|
* @param Int $id
|
||||||
* @param FieldSet $fields
|
* @param FieldList $fields
|
||||||
* @return Form
|
* @return Form
|
||||||
*/
|
*/
|
||||||
public function getEditForm($id = null, $fields = null) {
|
public function getEditForm($id = null, $fields = null) {
|
||||||
@ -847,7 +847,7 @@ class LeftAndMain extends Controller {
|
|||||||
$form = new Form(
|
$form = new Form(
|
||||||
$this,
|
$this,
|
||||||
"EditForm",
|
"EditForm",
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
// new HeaderField(
|
// new HeaderField(
|
||||||
// 'WelcomeHeader',
|
// 'WelcomeHeader',
|
||||||
// $this->getApplicationName()
|
// $this->getApplicationName()
|
||||||
@ -861,7 +861,7 @@ class LeftAndMain extends Controller {
|
|||||||
// )
|
// )
|
||||||
// )
|
// )
|
||||||
),
|
),
|
||||||
new FieldSet()
|
new FieldList()
|
||||||
);
|
);
|
||||||
$form->unsetValidator();
|
$form->unsetValidator();
|
||||||
$form->addExtraClass('cms-edit-form');
|
$form->addExtraClass('cms-edit-form');
|
||||||
@ -881,10 +881,10 @@ class LeftAndMain extends Controller {
|
|||||||
$form = new Form(
|
$form = new Form(
|
||||||
$this,
|
$this,
|
||||||
'AddForm',
|
'AddForm',
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new HiddenField('ParentID')
|
new HiddenField('ParentID')
|
||||||
),
|
),
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
$addAction = new FormAction('doAdd', _t('AssetAdmin_left.ss.GO','Go'))
|
$addAction = new FormAction('doAdd', _t('AssetAdmin_left.ss.GO','Go'))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -949,7 +949,7 @@ class LeftAndMain extends Controller {
|
|||||||
$form = new Form(
|
$form = new Form(
|
||||||
$this,
|
$this,
|
||||||
'BatchActionsForm',
|
'BatchActionsForm',
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new HiddenField('csvIDs'),
|
new HiddenField('csvIDs'),
|
||||||
new DropdownField(
|
new DropdownField(
|
||||||
'Action',
|
'Action',
|
||||||
@ -957,7 +957,7 @@ class LeftAndMain extends Controller {
|
|||||||
$actionsMap
|
$actionsMap
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
// TODO i18n
|
// TODO i18n
|
||||||
new FormAction('submit', "Go")
|
new FormAction('submit', "Go")
|
||||||
)
|
)
|
||||||
|
@ -34,7 +34,7 @@ class MemberImportForm extends Form {
|
|||||||
$importSpec = $importer->getImportSpec();
|
$importSpec = $importer->getImportSpec();
|
||||||
$helpHtml = sprintf($helpHtml, implode(', ', array_keys($importSpec['fields'])));
|
$helpHtml = sprintf($helpHtml, implode(', ', array_keys($importSpec['fields'])));
|
||||||
|
|
||||||
$fields = new FieldSet(
|
$fields = new FieldList(
|
||||||
new LiteralField('Help', $helpHtml),
|
new LiteralField('Help', $helpHtml),
|
||||||
$fileField = new FileField(
|
$fileField = new FileField(
|
||||||
'CsvFile',
|
'CsvFile',
|
||||||
@ -47,7 +47,7 @@ class MemberImportForm extends Form {
|
|||||||
$fileField->getValidator()->setAllowedExtensions(array('csv'));
|
$fileField->getValidator()->setAllowedExtensions(array('csv'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$actions) $actions = new FieldSet(
|
if(!$actions) $actions = new FieldList(
|
||||||
new FormAction('doImport', _t('SecurityAdmin_MemberImportForm.BtnImport', 'Import'))
|
new FormAction('doImport', _t('SecurityAdmin_MemberImportForm.BtnImport', 'Import'))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ class MemberTableField extends ComplexTableField {
|
|||||||
* Add existing member to group by name (with JS-autocompletion)
|
* Add existing member to group by name (with JS-autocompletion)
|
||||||
*/
|
*/
|
||||||
function AddRecordForm() {
|
function AddRecordForm() {
|
||||||
$fields = new FieldSet();
|
$fields = new FieldList();
|
||||||
foreach($this->FieldList() as $fieldName => $fieldTitle) {
|
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 we're adding the set password field, we want to hide the text from any peeping eyes
|
||||||
if($fieldName == 'SetPassword') {
|
if($fieldName == 'SetPassword') {
|
||||||
@ -240,7 +240,7 @@ class MemberTableField extends ComplexTableField {
|
|||||||
if($this->group) {
|
if($this->group) {
|
||||||
$fields->push(new HiddenField('ctf[ID]', null, $this->group->ID));
|
$fields->push(new HiddenField('ctf[ID]', null, $this->group->ID));
|
||||||
}
|
}
|
||||||
$actions = new FieldSet(
|
$actions = new FieldList(
|
||||||
new FormAction('addtogroup', _t('MemberTableField.ADD','Add'))
|
new FormAction('addtogroup', _t('MemberTableField.ADD','Add'))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -402,7 +402,7 @@ class ModelAdmin_CollectionController extends Controller {
|
|||||||
|
|
||||||
$form = new Form($this, "SearchForm",
|
$form = new Form($this, "SearchForm",
|
||||||
$fields,
|
$fields,
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new FormAction('search', _t('MemberTableField.SEARCH', 'Search')),
|
new FormAction('search', _t('MemberTableField.SEARCH', 'Search')),
|
||||||
$clearAction = new ResetFormAction('clearsearch', _t('ModelAdmin.CLEAR_SEARCH','Clear 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());
|
$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",
|
$form = new Form($this, "CreateForm",
|
||||||
new FieldSet(),
|
new FieldList(),
|
||||||
new FieldSet($createButton = new FormAction('add', $buttonLabel)),
|
new FieldList($createButton = new FormAction('add', $buttonLabel)),
|
||||||
$validator = new RequiredFields()
|
$validator = new RequiredFields()
|
||||||
);
|
);
|
||||||
$createButton->addExtraClass('ss-ui-action-constructive');
|
$createButton->addExtraClass('ss-ui-action-constructive');
|
||||||
@ -467,7 +467,7 @@ class ModelAdmin_CollectionController extends Controller {
|
|||||||
|
|
||||||
if(!singleton($modelName)->canCreate(Member::currentUser())) return false;
|
if(!singleton($modelName)->canCreate(Member::currentUser())) return false;
|
||||||
|
|
||||||
$fields = new FieldSet(
|
$fields = new FieldList(
|
||||||
new HiddenField('ClassName', _t('ModelAdmin.CLASSTYPE'), $modelName),
|
new HiddenField('ClassName', _t('ModelAdmin.CLASSTYPE'), $modelName),
|
||||||
new FileField('_CsvFile', false)
|
new FileField('_CsvFile', false)
|
||||||
);
|
);
|
||||||
@ -493,7 +493,7 @@ class ModelAdmin_CollectionController extends Controller {
|
|||||||
$fields->push(new LiteralField("SpecFor{$modelName}", $specHTML));
|
$fields->push(new LiteralField("SpecFor{$modelName}", $specHTML));
|
||||||
$fields->push(new CheckboxField('EmptyBeforeImport', 'Clear Database before import', false));
|
$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'))
|
new FormAction('import', _t('ModelAdmin.IMPORT', 'Import from CSV'))
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -766,11 +766,11 @@ class ModelAdmin_CollectionController extends Controller {
|
|||||||
$form = new Form(
|
$form = new Form(
|
||||||
$this,
|
$this,
|
||||||
'ResultsForm',
|
'ResultsForm',
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new HeaderField('SearchResults', _t('ModelAdmin.SEARCHRESULTS','Search Results'), 2),
|
new HeaderField('SearchResults', _t('ModelAdmin.SEARCHRESULTS','Search Results'), 2),
|
||||||
$tf
|
$tf
|
||||||
),
|
),
|
||||||
new FieldSet()
|
new FieldList()
|
||||||
);
|
);
|
||||||
|
|
||||||
// Include the search criteria on the results form URL, but not dodgy variables like those below
|
// 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();
|
if(!$validator) $validator = new RequiredFields();
|
||||||
$validator->setJavascriptValidationHandler('none');
|
$validator->setJavascriptValidationHandler('none');
|
||||||
|
|
||||||
$actions = new FieldSet (
|
$actions = new FieldList (
|
||||||
new FormAction("doCreate", _t('ModelAdmin.ADDBUTTON', "Add"))
|
new FormAction("doCreate", _t('ModelAdmin.ADDBUTTON', "Add"))
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1030,7 +1030,7 @@ class ModelAdmin_RecordController extends Controller {
|
|||||||
*/
|
*/
|
||||||
public function ViewForm() {
|
public function ViewForm() {
|
||||||
$fields = $this->currentRecord->getCMSFields();
|
$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->loadDataFrom($this->currentRecord);
|
||||||
$form->makeReadonly();
|
$form->makeReadonly();
|
||||||
return $form;
|
return $form;
|
||||||
|
@ -110,7 +110,7 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
|
|||||||
// unset 'inlineadd' permission, we don't want inline addition
|
// unset 'inlineadd' permission, we don't want inline addition
|
||||||
$memberList->setPermissions(array('edit', 'delete', 'add'));
|
$memberList->setPermissions(array('edit', 'delete', 'add'));
|
||||||
|
|
||||||
$fields = new FieldSet(
|
$fields = new FieldList(
|
||||||
new TabSet(
|
new TabSet(
|
||||||
'Root',
|
'Root',
|
||||||
new Tab('Members', singleton('Member')->i18n_plural_name(),
|
new Tab('Members', singleton('Member')->i18n_plural_name(),
|
||||||
@ -155,7 +155,7 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
|
|||||||
$rolesTab->push($rolesCTF);
|
$rolesTab->push($rolesCTF);
|
||||||
}
|
}
|
||||||
|
|
||||||
$actions = new FieldSet(
|
$actions = new FieldList(
|
||||||
new FormAction('addmember',_t('SecurityAdmin.ADDMEMBER','Add Member'))
|
new FormAction('addmember',_t('SecurityAdmin.ADDMEMBER','Add Member'))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -116,8 +116,8 @@ class MemberTableFieldTest_Controller extends Controller implements TestOnly {
|
|||||||
return new Form(
|
return new Form(
|
||||||
$this,
|
$this,
|
||||||
'FormNoGroup',
|
'FormNoGroup',
|
||||||
new FieldSet(new MemberTableField($this, "Members", $group1)),
|
new FieldList(new MemberTableField($this, "Members", $group1)),
|
||||||
new FieldSet(new FormAction('submit'))
|
new FieldList(new FormAction('submit'))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,8 +131,8 @@ class MemberTableFieldTest_Controller extends Controller implements TestOnly {
|
|||||||
return new Form(
|
return new Form(
|
||||||
$this,
|
$this,
|
||||||
'FormNoGroup',
|
'FormNoGroup',
|
||||||
new FieldSet(new MemberTableField($this, "Members")),
|
new FieldList(new MemberTableField($this, "Members")),
|
||||||
new FieldSet(new FormAction('submit'))
|
new FieldList(new FormAction('submit'))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -779,7 +779,7 @@ class File extends DataObject {
|
|||||||
* @return FieldSet
|
* @return FieldSet
|
||||||
*/
|
*/
|
||||||
function uploadMetadataFields() {
|
function uploadMetadataFields() {
|
||||||
$fields = new FieldSet();
|
$fields = new FieldList();
|
||||||
$fields->push(new TextField('Title', $this->fieldLabel('Title')));
|
$fields->push(new TextField('Title', $this->fieldLabel('Title')));
|
||||||
$this->extend('updateUploadMetadataFields', $fields);
|
$this->extend('updateUploadMetadataFields', $fields);
|
||||||
|
|
||||||
|
@ -386,7 +386,7 @@ class Folder extends File {
|
|||||||
/**
|
/**
|
||||||
* Return the FieldSet used to edit this folder in the CMS.
|
* 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}
|
* 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() {
|
function getCMSFields() {
|
||||||
$fileList = new AssetTableField(
|
$fileList = new AssetTableField(
|
||||||
@ -407,7 +407,7 @@ class Folder extends File {
|
|||||||
$deleteButton = new HiddenField('deletemarked');
|
$deleteButton = new HiddenField('deletemarked');
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields = new FieldSet(
|
$fields = new FieldList(
|
||||||
new HiddenField("Name"),
|
new HiddenField("Name"),
|
||||||
new TabSet("Root",
|
new TabSet("Root",
|
||||||
new Tab("Files", _t('Folder.FILESTAB', "Files"),
|
new Tab("Files", _t('Folder.FILESTAB', "Files"),
|
||||||
|
@ -189,7 +189,7 @@ class ComplexTableField extends TableListField {
|
|||||||
* @param string $name
|
* @param string $name
|
||||||
* @param string $sourceClass
|
* @param string $sourceClass
|
||||||
* @param array $fieldList
|
* @param array $fieldList
|
||||||
* @param FieldSet $detailFormFields
|
* @param FieldList $detailFormFields
|
||||||
* @param string $sourceFilter
|
* @param string $sourceFilter
|
||||||
* @param string $sourceSort
|
* @param string $sourceSort
|
||||||
* @param string $sourceJoin
|
* @param string $sourceJoin
|
||||||
@ -331,7 +331,7 @@ JS;
|
|||||||
* @return FieldSet
|
* @return FieldSet
|
||||||
*/
|
*/
|
||||||
function createFieldSet() {
|
function createFieldSet() {
|
||||||
$fieldset = new FieldSet();
|
$fieldset = new FieldList();
|
||||||
foreach($this->fieldTypes as $key => $fieldType){
|
foreach($this->fieldTypes as $key => $fieldType){
|
||||||
$fieldset->push(new $fieldType($key));
|
$fieldset->push(new $fieldType($key));
|
||||||
}
|
}
|
||||||
@ -813,7 +813,7 @@ class ComplexTableField_Popup extends Form {
|
|||||||
Requirements::clear();
|
Requirements::clear();
|
||||||
Requirements::unblock_all();
|
Requirements::unblock_all();
|
||||||
|
|
||||||
$actions = new FieldSet();
|
$actions = new FieldList();
|
||||||
if(!$readonly) {
|
if(!$readonly) {
|
||||||
$actions->push(
|
$actions->push(
|
||||||
$saveAction = new FormAction(
|
$saveAction = new FormAction(
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
class CompositeField extends FormField {
|
class CompositeField extends FormField {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var FieldSet
|
* @var FieldList
|
||||||
*/
|
*/
|
||||||
protected $children;
|
protected $children;
|
||||||
|
|
||||||
@ -29,13 +29,13 @@ class CompositeField extends FormField {
|
|||||||
protected $columnCount = null;
|
protected $columnCount = null;
|
||||||
|
|
||||||
public function __construct($children = null) {
|
public function __construct($children = null) {
|
||||||
if($children instanceof FieldSet) {
|
if($children instanceof FieldList) {
|
||||||
$this->children = $children;
|
$this->children = $children;
|
||||||
} elseif(is_array($children)) {
|
} elseif(is_array($children)) {
|
||||||
$this->children = new FieldSet($children);
|
$this->children = new FieldList($children);
|
||||||
} else {
|
} else {
|
||||||
$children = is_array(func_get_args()) ? func_get_args() : array();
|
$children = is_array(func_get_args()) ? func_get_args() : array();
|
||||||
$this->children = new FieldSet($children);
|
$this->children = new FieldList($children);
|
||||||
}
|
}
|
||||||
$this->children->setContainerField($this);
|
$this->children->setContainerField($this);
|
||||||
|
|
||||||
@ -46,10 +46,17 @@ class CompositeField extends FormField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all the sub-fields, suitable for <% control FieldSet %>
|
* Returns all the sub-fields, suitable for <% control FieldList %>
|
||||||
|
*/
|
||||||
|
public function FieldList() {
|
||||||
|
return $this->children;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated 3.0 Please use {@link FieldList()}.
|
||||||
*/
|
*/
|
||||||
public function FieldSet() {
|
public function FieldSet() {
|
||||||
return $this->children;
|
return $this->FieldList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setID($id) {
|
public function setID($id) {
|
||||||
@ -62,14 +69,14 @@ class CompositeField extends FormField {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Accessor method for $this->children
|
* Accessor method for $this->children
|
||||||
* @return FieldSet
|
* @return FieldList
|
||||||
*/
|
*/
|
||||||
public function getChildren() {
|
public function getChildren() {
|
||||||
return $this->children;
|
return $this->children;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param FieldSet $children
|
* @param FieldList $children
|
||||||
*/
|
*/
|
||||||
public function setChildren($children) {
|
public function setChildren($children) {
|
||||||
$this->children = $children;
|
$this->children = $children;
|
||||||
@ -79,7 +86,7 @@ class CompositeField extends FormField {
|
|||||||
* Returns the fields nested inside another DIV
|
* Returns the fields nested inside another DIV
|
||||||
*/
|
*/
|
||||||
function FieldHolder() {
|
function FieldHolder() {
|
||||||
$fs = $this->FieldSet();
|
$fs = $this->FieldList();
|
||||||
$idAtt = isset($this->id) ? " id=\"{$this->id}\"" : '';
|
$idAtt = isset($this->id) ? " id=\"{$this->id}\"" : '';
|
||||||
$className = ($this->columnCount) ? "field CompositeField {$this->extraClass()} multicolumn" : "field CompositeField {$this->extraClass()}";
|
$className = ($this->columnCount) ? "field CompositeField {$this->extraClass()} multicolumn" : "field CompositeField {$this->extraClass()}";
|
||||||
$content = "<div class=\"$className\"$idAtt>\n";
|
$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.
|
* Returns the fields in the restricted field holder inside a DIV.
|
||||||
*/
|
*/
|
||||||
function SmallFieldHolder() {//return $this->FieldHolder();
|
function SmallFieldHolder() {//return $this->FieldHolder();
|
||||||
$fs = $this->FieldSet();
|
$fs = $this->FieldList();
|
||||||
$idAtt = isset($this->id) ? " id=\"{$this->id}\"" : '';
|
$idAtt = isset($this->id) ? " id=\"{$this->id}\"" : '';
|
||||||
$className = ($this->columnCount) ? "field CompositeField {$this->extraClass()} multicolumn" : "field CompositeField {$this->extraClass()}";
|
$className = ($this->columnCount) ? "field CompositeField {$this->extraClass()} multicolumn" : "field CompositeField {$this->extraClass()}";
|
||||||
$content = "<div class=\"$className\"$idAtt>";
|
$content = "<div class=\"$className\"$idAtt>";
|
||||||
@ -168,7 +175,7 @@ class CompositeField extends FormField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @uses FieldSet->insertBefore()
|
* @uses FieldList->insertBefore()
|
||||||
*/
|
*/
|
||||||
public function insertBefore($field, $insertBefore) {
|
public function insertBefore($field, $insertBefore) {
|
||||||
$ret = $this->children->insertBefore($field, $insertBefore);
|
$ret = $this->children->insertBefore($field, $insertBefore);
|
||||||
@ -209,7 +216,7 @@ class CompositeField extends FormField {
|
|||||||
* versions of all the children
|
* versions of all the children
|
||||||
*/
|
*/
|
||||||
public function performReadonlyTransformation() {
|
public function performReadonlyTransformation() {
|
||||||
$newChildren = new FieldSet();
|
$newChildren = new FieldList();
|
||||||
$clone = clone $this;
|
$clone = clone $this;
|
||||||
foreach($clone->getChildren() as $idx => $child) {
|
foreach($clone->getChildren() as $idx => $child) {
|
||||||
if(is_object($child)) $child = $child->transform(new ReadonlyTransformation());
|
if(is_object($child)) $child = $child->transform(new ReadonlyTransformation());
|
||||||
@ -226,7 +233,7 @@ class CompositeField extends FormField {
|
|||||||
* versions of all the children
|
* versions of all the children
|
||||||
*/
|
*/
|
||||||
public function performDisabledTransformation($trans) {
|
public function performDisabledTransformation($trans) {
|
||||||
$newChildren = new FieldSet();
|
$newChildren = new FieldList();
|
||||||
$clone = clone $this;
|
$clone = clone $this;
|
||||||
if($clone->getChildren()) foreach($clone->getChildren() as $idx => $child) {
|
if($clone->getChildren()) foreach($clone->getChildren() as $idx => $child) {
|
||||||
if(is_object($child)) {
|
if(is_object($child)) {
|
||||||
|
@ -69,7 +69,7 @@ class ConfirmedPasswordField extends FormField {
|
|||||||
*/
|
*/
|
||||||
function __construct($name, $title = null, $value = "", $form = null, $showOnClick = false, $titleConfirmField = null) {
|
function __construct($name, $title = null, $value = "", $form = null, $showOnClick = false, $titleConfirmField = null) {
|
||||||
// naming with underscores to prevent values from actually being saved somewhere
|
// naming with underscores to prevent values from actually being saved somewhere
|
||||||
$this->children = new FieldSet(
|
$this->children = new FieldList(
|
||||||
new PasswordField(
|
new PasswordField(
|
||||||
"{$name}[_Password]",
|
"{$name}[_Password]",
|
||||||
(isset($title)) ? $title : _t('Member.PASSWORD', 'Password')
|
(isset($title)) ? $title : _t('Member.PASSWORD', 'Password')
|
||||||
|
@ -441,7 +441,7 @@ class FieldList extends ArrayList {
|
|||||||
*/
|
*/
|
||||||
function transform($trans) {
|
function transform($trans) {
|
||||||
$this->flushFieldsCache();
|
$this->flushFieldsCache();
|
||||||
$newFields = new FieldSet();
|
$newFields = new FieldList();
|
||||||
foreach($this as $field) {
|
foreach($this as $field) {
|
||||||
$newFields->push($field->transform($trans));
|
$newFields->push($field->transform($trans));
|
||||||
}
|
}
|
||||||
|
@ -17,11 +17,11 @@
|
|||||||
* class ExampleForm_Controller extends Page_Controller {
|
* class ExampleForm_Controller extends Page_Controller {
|
||||||
*
|
*
|
||||||
* public function Form() {
|
* public function Form() {
|
||||||
* $fields = new FieldSet(
|
* $fields = new FieldList(
|
||||||
* new TextField('MyName'),
|
* new TextField('MyName'),
|
||||||
* new FileField('MyFile')
|
* new FileField('MyFile')
|
||||||
* );
|
* );
|
||||||
* $actions = new FieldSet(
|
* $actions = new FieldList(
|
||||||
* new FormAction('doUpload', 'Upload file')
|
* new FormAction('doUpload', 'Upload file')
|
||||||
* );
|
* );
|
||||||
* $validator = new RequiredFields(array('MyName', 'MyFile'));
|
* $validator = new RequiredFields(array('MyName', 'MyFile'));
|
||||||
|
@ -137,7 +137,7 @@ class FileIFrameField extends FileField {
|
|||||||
|
|
||||||
$fileSources["existing//$selectFile"] = new TreeDropdownField('ExistingFile', '', 'File');
|
$fileSources["existing//$selectFile"] = new TreeDropdownField('ExistingFile', '', 'File');
|
||||||
|
|
||||||
$fields = new FieldSet (
|
$fields = new FieldList (
|
||||||
new HeaderField('EditFileHeader', $title),
|
new HeaderField('EditFileHeader', $title),
|
||||||
new SelectionGroup('FileSource', $fileSources)
|
new SelectionGroup('FileSource', $fileSources)
|
||||||
);
|
);
|
||||||
@ -151,7 +151,7 @@ class FileIFrameField extends FileField {
|
|||||||
$this,
|
$this,
|
||||||
'EditFileForm',
|
'EditFileForm',
|
||||||
$fields,
|
$fields,
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new FormAction('save', $title)
|
new FormAction('save', $title)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -223,10 +223,10 @@ class FileIFrameField extends FileField {
|
|||||||
$form = new Form (
|
$form = new Form (
|
||||||
$this,
|
$this,
|
||||||
'DeleteFileForm',
|
'DeleteFileForm',
|
||||||
new FieldSet (
|
new FieldList (
|
||||||
new HiddenField('DeleteFile', null, false)
|
new HiddenField('DeleteFile', null, false)
|
||||||
),
|
),
|
||||||
new FieldSet (
|
new FieldList (
|
||||||
$deleteButton = new FormAction (
|
$deleteButton = new FormAction (
|
||||||
'delete', sprintf(_t('FileIFrameField.DELETE', 'Delete %s'), $this->FileTypeName())
|
'delete', sprintf(_t('FileIFrameField.DELETE', 'Delete %s'), $this->FileTypeName())
|
||||||
)
|
)
|
||||||
|
@ -142,15 +142,15 @@ class Form extends RequestHandler {
|
|||||||
*
|
*
|
||||||
* @param Controller $controller The parent controller, necessary to create the appropriate form action tag.
|
* @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 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 FieldList $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 $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})
|
* @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();
|
parent::__construct();
|
||||||
|
|
||||||
if(!$fields 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 FieldSet) throw new InvalidArgumentException('$fields must be a valid FieldSet 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');
|
if($validator && !$validator instanceof Validator) throw new InvalidArgumentException('$validator must be a Valdidator instance');
|
||||||
|
|
||||||
$fields->setForm($this);
|
$fields->setForm($this);
|
||||||
@ -398,13 +398,13 @@ class Form extends RequestHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function transform(FormTransformation $trans) {
|
function transform(FormTransformation $trans) {
|
||||||
$newFields = new FieldSet();
|
$newFields = new FieldList();
|
||||||
foreach($this->fields as $field) {
|
foreach($this->fields as $field) {
|
||||||
$newFields->push($field->transform($trans));
|
$newFields->push($field->transform($trans));
|
||||||
}
|
}
|
||||||
$this->fields = $newFields;
|
$this->fields = $newFields;
|
||||||
|
|
||||||
$newActions = new FieldSet();
|
$newActions = new FieldList();
|
||||||
foreach($this->actions as $action) {
|
foreach($this->actions as $action) {
|
||||||
$newActions->push($action->transform($trans));
|
$newActions->push($action->transform($trans));
|
||||||
}
|
}
|
||||||
@ -445,7 +445,7 @@ class Form extends RequestHandler {
|
|||||||
* Convert this form to another format.
|
* Convert this form to another format.
|
||||||
*/
|
*/
|
||||||
function transformTo(FormTransformation $format) {
|
function transformTo(FormTransformation $format) {
|
||||||
$newFields = new FieldSet();
|
$newFields = new FieldList();
|
||||||
foreach($this->fields as $field) {
|
foreach($this->fields as $field) {
|
||||||
$newFields->push($field->transformTo($format));
|
$newFields->push($field->transformTo($format));
|
||||||
}
|
}
|
||||||
@ -463,7 +463,7 @@ class Form extends RequestHandler {
|
|||||||
* @return FieldSet
|
* @return FieldSet
|
||||||
*/
|
*/
|
||||||
public function getExtraFields() {
|
public function getExtraFields() {
|
||||||
$extraFields = new FieldSet();
|
$extraFields = new FieldList();
|
||||||
|
|
||||||
$token = $this->getSecurityToken();
|
$token = $this->getSecurityToken();
|
||||||
$tokenField = $token->updateFieldSet($this->fields);
|
$tokenField = $token->updateFieldSet($this->fields);
|
||||||
@ -507,7 +507,7 @@ class Form extends RequestHandler {
|
|||||||
/**
|
/**
|
||||||
* Setter for the form fields.
|
* Setter for the form fields.
|
||||||
*
|
*
|
||||||
* @param FieldSet $fields
|
* @param FieldList $fields
|
||||||
*/
|
*/
|
||||||
function setFields($fields) {
|
function setFields($fields) {
|
||||||
$this->fields = $fields;
|
$this->fields = $fields;
|
||||||
@ -540,7 +540,7 @@ class Form extends RequestHandler {
|
|||||||
/**
|
/**
|
||||||
* Setter for the form actions.
|
* Setter for the form actions.
|
||||||
*
|
*
|
||||||
* @param FieldSet $actions
|
* @param FieldList $actions
|
||||||
*/
|
*/
|
||||||
function setActions($actions) {
|
function setActions($actions) {
|
||||||
$this->actions = $actions;
|
$this->actions = $actions;
|
||||||
@ -550,7 +550,7 @@ class Form extends RequestHandler {
|
|||||||
* Unset all form actions
|
* Unset all form actions
|
||||||
*/
|
*/
|
||||||
function unsetAllActions(){
|
function unsetAllActions(){
|
||||||
$this->actions = new FieldSet();
|
$this->actions = new FieldList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -653,7 +653,7 @@ HTML;
|
|||||||
/**
|
/**
|
||||||
* Set the fieldset that contains this field.
|
* Set the fieldset that contains this field.
|
||||||
*
|
*
|
||||||
* @param FieldSet $containerFieldSet
|
* @param FieldList $containerFieldSet
|
||||||
*/
|
*/
|
||||||
function setContainerFieldSet($containerFieldSet) {
|
function setContainerFieldSet($containerFieldSet) {
|
||||||
$this->containerFieldSet = $containerFieldSet;
|
$this->containerFieldSet = $containerFieldSet;
|
||||||
|
@ -65,7 +65,7 @@ class FormScaffolder extends Object {
|
|||||||
* @return FieldSet
|
* @return FieldSet
|
||||||
*/
|
*/
|
||||||
public function getFieldSet() {
|
public function getFieldSet() {
|
||||||
$fields = new FieldSet();
|
$fields = new FieldList();
|
||||||
|
|
||||||
// tabbed or untabbed
|
// tabbed or untabbed
|
||||||
if($this->tabbed) {
|
if($this->tabbed) {
|
||||||
|
@ -235,7 +235,7 @@ class HtmlEditorField_Toolbar extends RequestHandler {
|
|||||||
$form = new Form(
|
$form = new Form(
|
||||||
$this->controller,
|
$this->controller,
|
||||||
"{$this->name}/LinkForm",
|
"{$this->name}/LinkForm",
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new LiteralField(
|
new LiteralField(
|
||||||
'Heading',
|
'Heading',
|
||||||
sprintf('<h3>%s</h3>', _t('HtmlEditorField.LINK', 'Link'))
|
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 HiddenField('Locale', null, $this->controller->Locale)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new FormAction('insert', _t('HtmlEditorField.BUTTONINSERTLINK', 'Insert link')),
|
new FormAction('insert', _t('HtmlEditorField.BUTTONINSERTLINK', 'Insert link')),
|
||||||
new FormAction('remove', _t('HtmlEditorField.BUTTONREMOVELINK', 'Remove 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()');
|
throw new Exception('ThumbnailStripField class required for HtmlEditorField->ImageForm()');
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields = new FieldSet(
|
$fields = new FieldList(
|
||||||
new LiteralField(
|
new LiteralField(
|
||||||
'Heading',
|
'Heading',
|
||||||
sprintf('<h3>%s</h3>', _t('HtmlEditorField.IMAGE', 'Image'))
|
sprintf('<h3>%s</h3>', _t('HtmlEditorField.IMAGE', 'Image'))
|
||||||
@ -299,7 +299,7 @@ class HtmlEditorField_Toolbar extends RequestHandler {
|
|||||||
|
|
||||||
$contentComposite = new CompositeField(
|
$contentComposite = new CompositeField(
|
||||||
new TreeDropdownField('FolderID', _t('HtmlEditorField.FOLDER', 'Folder'), 'Folder'),
|
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 LiteralField('ShowUpload', '<p class="showUploadField"><a href="#">'. _t('HtmlEditorField.SHOWUPLOADFORM', 'Upload File') .'</a></p>'),
|
||||||
new FileField("Files[0]" , _t('AssetAdmin.CHOOSEFILE','Choose file: ')),
|
new FileField("Files[0]" , _t('AssetAdmin.CHOOSEFILE','Choose file: ')),
|
||||||
new LiteralField('Response', '<div id="UploadFormResponse"></div>'),
|
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'))
|
new FormAction('insertimage', _t('HtmlEditorField.BUTTONINSERTIMAGE', 'Insert image'))
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -359,7 +359,7 @@ class HtmlEditorField_Toolbar extends RequestHandler {
|
|||||||
$form = new Form(
|
$form = new Form(
|
||||||
$this->controller,
|
$this->controller,
|
||||||
"{$this->name}/FlashForm",
|
"{$this->name}/FlashForm",
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new LiteralField(
|
new LiteralField(
|
||||||
'Heading',
|
'Heading',
|
||||||
sprintf('<h3>%s</h3>', _t('HtmlEditorField.FLASH', 'Flash'))
|
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'))
|
new FormAction("insertflash", _t('HtmlEditorField.BUTTONINSERTFLASH', 'Insert Flash'))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
* $map = $myDoSet->toDropDownMap();
|
* $map = $myDoSet->toDropDownMap();
|
||||||
*
|
*
|
||||||
* // Instantiate the OptionsetField
|
* // Instantiate the OptionsetField
|
||||||
* $fieldset = new Fieldset(
|
* $fieldset = new FieldList(
|
||||||
* new OptionsetField(
|
* new OptionsetField(
|
||||||
* $name = "Foobar",
|
* $name = "Foobar",
|
||||||
* $title = "FooBar's optionset",
|
* $title = "FooBar's optionset",
|
||||||
|
@ -16,7 +16,7 @@ class ScaffoldingComplexTableField_Popup extends ComplexTableField_Popup {
|
|||||||
|
|
||||||
Requirements::clear();
|
Requirements::clear();
|
||||||
|
|
||||||
$actions = new FieldSet();
|
$actions = new FieldList();
|
||||||
if(!$readonly) {
|
if(!$readonly) {
|
||||||
$actions->push(
|
$actions->push(
|
||||||
$saveAction = new FormAction("saveComplexTableField", "Save")
|
$saveAction = new FormAction("saveComplexTableField", "Save")
|
||||||
|
@ -42,7 +42,7 @@ class SelectionGroup extends CompositeField {
|
|||||||
$newChildren[$idx] = $child;
|
$newChildren[$idx] = $child;
|
||||||
}
|
}
|
||||||
|
|
||||||
$clone->setChildren(new FieldSet($newChildren));
|
$clone->setChildren(new FieldList($newChildren));
|
||||||
$clone->setReadonly(true);
|
$clone->setReadonly(true);
|
||||||
return $clone;
|
return $clone;
|
||||||
}
|
}
|
||||||
|
@ -32,12 +32,12 @@
|
|||||||
*
|
*
|
||||||
* <code>
|
* <code>
|
||||||
* function Form() {
|
* function Form() {
|
||||||
* return new Form($this, "Form", new FieldSet(
|
* return new Form($this, "Form", new FieldList(
|
||||||
* new SimpleImageField (
|
* new SimpleImageField (
|
||||||
* $name = "FileTypeID",
|
* $name = "FileTypeID",
|
||||||
* $title = "Upload your FileType"
|
* $title = "Upload your FileType"
|
||||||
* )
|
* )
|
||||||
* ), new FieldSet(
|
* ), new FieldList(
|
||||||
*
|
*
|
||||||
* // List the action buttons here - doform executes the function 'doform' below
|
* // List the action buttons here - doform executes the function 'doform' below
|
||||||
* new FormAction("doform", "Submit")
|
* new FormAction("doform", "Submit")
|
||||||
|
@ -217,7 +217,7 @@ class TableField extends TableListField {
|
|||||||
$this,
|
$this,
|
||||||
null,
|
null,
|
||||||
$this->FieldSetForRow(),
|
$this->FieldSetForRow(),
|
||||||
new FieldSet()
|
new FieldList()
|
||||||
);
|
);
|
||||||
$form->loadDataFrom($dataObj);
|
$form->loadDataFrom($dataObj);
|
||||||
|
|
||||||
@ -281,7 +281,7 @@ class TableField extends TableListField {
|
|||||||
* @return FieldSet
|
* @return FieldSet
|
||||||
*/
|
*/
|
||||||
function FieldSetForRow() {
|
function FieldSetForRow() {
|
||||||
$fieldset = new FieldSet();
|
$fieldset = new FieldList();
|
||||||
if($this->fieldTypes){
|
if($this->fieldTypes){
|
||||||
foreach($this->fieldTypes as $key => $fieldType) {
|
foreach($this->fieldTypes as $key => $fieldType) {
|
||||||
if(isset($fieldType->class) && is_subclass_of($fieldType, 'FormField')) {
|
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) {
|
foreach ($dataObjects as $objectid => $fieldValues) {
|
||||||
// 'new' counts as an empty column, don't save it
|
// 'new' counts as an empty column, don't save it
|
||||||
@ -592,7 +592,7 @@ JS;
|
|||||||
class TableField_Item extends TableListField_Item {
|
class TableField_Item extends TableListField_Item {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var FieldSet $fields
|
* @var FieldList $fields
|
||||||
*/
|
*/
|
||||||
protected $fields;
|
protected $fields;
|
||||||
|
|
||||||
@ -719,7 +719,7 @@ class TableField_Item extends TableListField_Item {
|
|||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new FieldSet($this->fields);
|
return new FieldList($this->fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
function Fields() {
|
function Fields() {
|
||||||
|
@ -160,11 +160,11 @@ abstract class DataExtension extends Extension {
|
|||||||
* should just be used to add or modify tabs, or fields which
|
* should just be used to add or modify tabs, or fields which
|
||||||
* are specific to the CMS-context.
|
* 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.
|
* 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
|
* This is used to provide modifications to the form actions
|
||||||
* used in the CMS. {@link DataObject->getCMSActions()}.
|
* used in the CMS. {@link DataObject->getCMSActions()}.
|
||||||
*
|
*
|
||||||
* @param FieldSet $actions FieldSet
|
* @param FieldList $actions FieldSet
|
||||||
*/
|
*/
|
||||||
function updateCMSActions(FieldSet &$actions) {
|
function updateCMSActions(FieldList $actions) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1782,7 +1782,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
),
|
),
|
||||||
(array)$_params
|
(array)$_params
|
||||||
);
|
);
|
||||||
$fields = new FieldSet();
|
$fields = new FieldList();
|
||||||
foreach($this->searchableFields() as $fieldName => $spec) {
|
foreach($this->searchableFields() as $fieldName => $spec) {
|
||||||
if($params['restrictFields'] && !in_array($fieldName, $params['restrictFields'])) continue;
|
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
|
* @return an Empty FieldSet(); need to be overload by solid subclass
|
||||||
*/
|
*/
|
||||||
public function getCMSActions() {
|
public function getCMSActions() {
|
||||||
$actions = new FieldSet();
|
$actions = new FieldList();
|
||||||
$this->extend('updateCMSActions', $actions);
|
$this->extend('updateCMSActions', $actions);
|
||||||
return $actions;
|
return $actions;
|
||||||
}
|
}
|
||||||
|
@ -63,14 +63,14 @@ class SearchContext extends Object {
|
|||||||
*
|
*
|
||||||
* @param string $modelClass The base {@link DataObject} class that search properties related to.
|
* @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.
|
* 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
|
* which are to be searched. Derived from modelclass using
|
||||||
* {@link DataObject::scaffoldSearchFields()} if left blank.
|
* {@link DataObject::scaffoldSearchFields()} if left blank.
|
||||||
* @param array $filters Optional. Derived from modelclass if left blank
|
* @param array $filters Optional. Derived from modelclass if left blank
|
||||||
*/
|
*/
|
||||||
function __construct($modelClass, $fields = null, $filters = null) {
|
function __construct($modelClass, $fields = null, $filters = null) {
|
||||||
$this->modelClass = $modelClass;
|
$this->modelClass = $modelClass;
|
||||||
$this->fields = ($fields) ? $fields : new FieldSet();
|
$this->fields = ($fields) ? $fields : new FieldList();
|
||||||
$this->filters = ($filters) ? $filters : array();
|
$this->filters = ($filters) ? $filters : array();
|
||||||
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
@ -241,7 +241,7 @@ class SearchContext extends Object {
|
|||||||
/**
|
/**
|
||||||
* Apply a list of searchable fields to the current search context.
|
* Apply a list of searchable fields to the current search context.
|
||||||
*
|
*
|
||||||
* @param FieldSet $fields
|
* @param FieldList $fields
|
||||||
*/
|
*/
|
||||||
public function setFields($fields) {
|
public function setFields($fields) {
|
||||||
$this->fields = $fields;
|
$this->fields = $fields;
|
||||||
|
@ -27,7 +27,7 @@ class ChangePasswordForm extends Form {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!$fields) {
|
if(!$fields) {
|
||||||
$fields = new FieldSet();
|
$fields = new FieldList();
|
||||||
|
|
||||||
// Security/changepassword?h=XXX redirects to Security/changepassword
|
// Security/changepassword?h=XXX redirects to Security/changepassword
|
||||||
// without GET parameter to avoid potential HTTP referer leakage.
|
// 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")));
|
$fields->push(new PasswordField("NewPassword2", _t('Member.CONFIRMNEWPASSWORD', "Confirm New Password")));
|
||||||
}
|
}
|
||||||
if(!$actions) {
|
if(!$actions) {
|
||||||
$actions = new FieldSet(
|
$actions = new FieldList(
|
||||||
new FormAction("doChangePassword", _t('Member.BUTTONCHANGEPASSWORD', "Change Password"))
|
new FormAction("doChangePassword", _t('Member.BUTTONCHANGEPASSWORD', "Change Password"))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ class Group extends DataObject {
|
|||||||
public function getCMSFields() {
|
public function getCMSFields() {
|
||||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/PermissionCheckboxSetField.js');
|
Requirements::javascript(SAPPHIRE_DIR . '/javascript/PermissionCheckboxSetField.js');
|
||||||
|
|
||||||
$fields = new FieldSet(
|
$fields = new FieldList(
|
||||||
new TabSet("Root",
|
new TabSet("Root",
|
||||||
new Tab('Members', _t('SecurityAdmin.MEMBERS', 'Members'),
|
new Tab('Members', _t('SecurityAdmin.MEMBERS', 'Members'),
|
||||||
new TextField("Title", $this->fieldLabel('Title')),
|
new TextField("Title", $this->fieldLabel('Title')),
|
||||||
|
@ -1570,7 +1570,7 @@ class Member_ProfileForm extends Form {
|
|||||||
$fields = $member->getCMSFields();
|
$fields = $member->getCMSFields();
|
||||||
$fields->push(new HiddenField('ID','ID',$member->ID));
|
$fields->push(new HiddenField('ID','ID',$member->ID));
|
||||||
|
|
||||||
$actions = new FieldSet(
|
$actions = new FieldList(
|
||||||
new FormAction('dosave',_t('CMSMain.SAVE', 'Save'))
|
new FormAction('dosave',_t('CMSMain.SAVE', 'Save'))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -50,16 +50,16 @@ class MemberLoginForm extends LoginForm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($checkCurrentUser && Member::currentUser() && Member::logged_in_session_exists()) {
|
if($checkCurrentUser && Member::currentUser() && Member::logged_in_session_exists()) {
|
||||||
$fields = new FieldSet(
|
$fields = new FieldList(
|
||||||
new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this)
|
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"))
|
new FormAction("logout", _t('Member.BUTTONLOGINOTHER', "Log in as someone else"))
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if(!$fields) {
|
if(!$fields) {
|
||||||
$label=singleton('Member')->fieldLabel(Member::get_unique_identifier_field());
|
$label=singleton('Member')->fieldLabel(Member::get_unique_identifier_field());
|
||||||
$fields = new FieldSet(
|
$fields = new FieldList(
|
||||||
new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this),
|
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:
|
//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),
|
new TextField("Email", $label, Session::get('SessionForms.MemberLoginForm.Email'), null, $this),
|
||||||
@ -73,7 +73,7 @@ class MemberLoginForm extends LoginForm {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!$actions) {
|
if(!$actions) {
|
||||||
$actions = new FieldSet(
|
$actions = new FieldList(
|
||||||
new FormAction('dologin', _t('Member.BUTTONLOGIN', "Log in")),
|
new FormAction('dologin', _t('Member.BUTTONLOGIN', "Log in")),
|
||||||
new LiteralField(
|
new LiteralField(
|
||||||
'forgotPassword',
|
'forgotPassword',
|
||||||
|
@ -470,10 +470,10 @@ class Security extends Controller {
|
|||||||
return Object::create('MemberLoginForm',
|
return Object::create('MemberLoginForm',
|
||||||
$this,
|
$this,
|
||||||
'LostPasswordForm',
|
'LostPasswordForm',
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new EmailField('Email', _t('Member.EMAIL', 'Email'))
|
new EmailField('Email', _t('Member.EMAIL', 'Email'))
|
||||||
),
|
),
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new FormAction(
|
new FormAction(
|
||||||
'forgotPassword',
|
'forgotPassword',
|
||||||
_t('Security.BUTTONSEND', 'Send me the password reset link')
|
_t('Security.BUTTONSEND', 'Send me the password reset link')
|
||||||
|
@ -164,7 +164,7 @@ class SecurityToken extends Object {
|
|||||||
* on the returned {@link HiddenField}, you'll need to take
|
* on the returned {@link HiddenField}, you'll need to take
|
||||||
* care of this yourself.
|
* care of this yourself.
|
||||||
*
|
*
|
||||||
* @param FieldSet $fieldset
|
* @param FieldList $fieldset
|
||||||
* @return HiddenField|false
|
* @return HiddenField|false
|
||||||
*/
|
*/
|
||||||
function updateFieldSet(&$fieldset) {
|
function updateFieldSet(&$fieldset) {
|
||||||
@ -234,7 +234,7 @@ class NullSecurityToken extends SecurityToken {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param FieldSet $fieldset
|
* @param FieldList $fieldset
|
||||||
* @return false
|
* @return false
|
||||||
*/
|
*/
|
||||||
function updateFieldSet(&$fieldset) {
|
function updateFieldSet(&$fieldset) {
|
||||||
|
@ -298,10 +298,10 @@ class RequestHandlingTest_Controller extends Controller implements TestOnly {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function TestForm() {
|
function TestForm() {
|
||||||
return new RequestHandlingTest_Form($this, "TestForm", new FieldSet(
|
return new RequestHandlingTest_Form($this, "TestForm", new FieldList(
|
||||||
new RequestHandlingTest_FormField("MyField"),
|
new RequestHandlingTest_FormField("MyField"),
|
||||||
new RequestHandlingTest_SubclassedFormField("SubclassedField")
|
new RequestHandlingTest_SubclassedFormField("SubclassedField")
|
||||||
), new FieldSet(
|
), new FieldList(
|
||||||
new FormAction("myAction")
|
new FormAction("myAction")
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -350,10 +350,10 @@ class RequestHandlingTest_FormActionController extends Controller {
|
|||||||
return new Form(
|
return new Form(
|
||||||
$this,
|
$this,
|
||||||
"Form",
|
"Form",
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new TextField("MyField")
|
new TextField("MyField")
|
||||||
),
|
),
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new FormAction("formaction"),
|
new FormAction("formaction"),
|
||||||
new FormAction('formactionInAllowedActions')
|
new FormAction('formactionInAllowedActions')
|
||||||
)
|
)
|
||||||
@ -472,8 +472,8 @@ class RequestHandlingTest_ControllerFormWithAllowedActions extends Controller im
|
|||||||
return new RequestHandlingTest_FormWithAllowedActions(
|
return new RequestHandlingTest_FormWithAllowedActions(
|
||||||
$this,
|
$this,
|
||||||
'Form',
|
'Form',
|
||||||
new FieldSet(),
|
new FieldList(),
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new FormAction('allowedformaction'),
|
new FormAction('allowedformaction'),
|
||||||
new FormAction('disallowedformaction') // disallowed through $allowed_actions in form
|
new FormAction('disallowedformaction') // disallowed through $allowed_actions in form
|
||||||
)
|
)
|
||||||
|
@ -117,8 +117,8 @@ class CheckboxSetFieldTest extends SapphireTest {
|
|||||||
$form = new Form(
|
$form = new Form(
|
||||||
new Controller(),
|
new Controller(),
|
||||||
'Form',
|
'Form',
|
||||||
new FieldSet($field),
|
new FieldList($field),
|
||||||
new FieldSet()
|
new FieldList()
|
||||||
);
|
);
|
||||||
$form->loadDataFrom($articleWithTags);
|
$form->loadDataFrom($articleWithTags);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
|
@ -108,11 +108,11 @@ class ComplexTableFieldTest_Controller extends Controller {
|
|||||||
$form = new Form(
|
$form = new Form(
|
||||||
$this,
|
$this,
|
||||||
'ManyManyForm',
|
'ManyManyForm',
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new HiddenField('ID', '', $team->ID),
|
new HiddenField('ID', '', $team->ID),
|
||||||
$playersField
|
$playersField
|
||||||
),
|
),
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new FormAction('doSubmit', 'Submit')
|
new FormAction('doSubmit', 'Submit')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -137,11 +137,11 @@ class ComplexTableFieldTest_Controller extends Controller {
|
|||||||
$form = new Form(
|
$form = new Form(
|
||||||
$this,
|
$this,
|
||||||
'HasManyForm',
|
'HasManyForm',
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new HiddenField('ID', '', $team->ID),
|
new HiddenField('ID', '', $team->ID),
|
||||||
$sponsorsField
|
$sponsorsField
|
||||||
),
|
),
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new FormAction('doSubmit', 'Submit')
|
new FormAction('doSubmit', 'Submit')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -22,10 +22,10 @@ class DatetimeFieldTest extends SapphireTest {
|
|||||||
$form = new Form(
|
$form = new Form(
|
||||||
new Controller(),
|
new Controller(),
|
||||||
'Form',
|
'Form',
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
$f = new DatetimeField('MyDatetime', null)
|
$f = new DatetimeField('MyDatetime', null)
|
||||||
),
|
),
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new FormAction('doSubmit')
|
new FormAction('doSubmit')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -1,34 +1,34 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for FieldSet
|
* Tests for FieldList
|
||||||
*
|
*
|
||||||
* @package sapphire
|
* @package sapphire
|
||||||
* @subpackage tests
|
* @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.
|
* that the values that were set are the correct ones given back.
|
||||||
* @todo test for {@link FieldSet->transform()} and {@link FieldSet->makeReadonly()}.
|
* @todo test for {@link FieldList->transform()} and {@link FieldList->makeReadonly()}.
|
||||||
* Need to ensure that it correctly transforms the FieldSet object.
|
* Need to ensure that it correctly transforms the FieldList object.
|
||||||
* @todo test for {@link FieldSet->HiddenFields()}. Need to check
|
* @todo test for {@link FieldList->HiddenFields()}. Need to check
|
||||||
* the fields returned are the correct HiddenField objects for a
|
* the fields returned are the correct HiddenField objects for a
|
||||||
* given FieldSet instance.
|
* given FieldList instance.
|
||||||
* @todo test for {@link FieldSet->dataFields()}.
|
* @todo test for {@link FieldList->dataFields()}.
|
||||||
* @todo test for {@link FieldSet->findOrMakeTab()}.
|
* @todo test for {@link FieldList->findOrMakeTab()}.
|
||||||
* @todo the same as above with insertBefore() and insertAfter()
|
* @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.
|
* Test adding a field to a tab in a set.
|
||||||
*/
|
*/
|
||||||
function testAddFieldToTab() {
|
function testAddFieldToTab() {
|
||||||
$fields = new FieldSet();
|
$fields = new FieldList();
|
||||||
$tab = new Tab('Root');
|
$tab = new Tab('Root');
|
||||||
$fields->push($tab);
|
$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->addFieldToTab('Root', new TextField('Country'));
|
||||||
$fields->addFieldsToTab('Root', array(
|
$fields->addFieldsToTab('Root', array(
|
||||||
new EmailField('Email'),
|
new EmailField('Email'),
|
||||||
@ -53,7 +53,7 @@ class FieldSetTest extends SapphireTest {
|
|||||||
* Test removing a single field from a tab in a set.
|
* Test removing a single field from a tab in a set.
|
||||||
*/
|
*/
|
||||||
function testRemoveSingleFieldFromTab() {
|
function testRemoveSingleFieldFromTab() {
|
||||||
$fields = new FieldSet();
|
$fields = new FieldList();
|
||||||
$tab = new Tab('Root');
|
$tab = new Tab('Root');
|
||||||
$fields->push($tab);
|
$fields->push($tab);
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ class FieldSetTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function testRemoveTab() {
|
function testRemoveTab() {
|
||||||
$fields = new FieldSet(new TabSet(
|
$fields = new FieldList(new TabSet(
|
||||||
'Root',
|
'Root',
|
||||||
$tab1 = new Tab('Tab1'),
|
$tab1 = new Tab('Tab1'),
|
||||||
$tab2 = new Tab('Tab2'),
|
$tab2 = new Tab('Tab2'),
|
||||||
@ -85,12 +85,12 @@ class FieldSetTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function testHasTabSet() {
|
function testHasTabSet() {
|
||||||
$untabbedFields = new FieldSet(
|
$untabbedFields = new FieldList(
|
||||||
new TextField('Field1')
|
new TextField('Field1')
|
||||||
);
|
);
|
||||||
$this->assertFalse($untabbedFields->hasTabSet());
|
$this->assertFalse($untabbedFields->hasTabSet());
|
||||||
|
|
||||||
$tabbedFields = new FieldSet(
|
$tabbedFields = new FieldList(
|
||||||
new TabSet('Root',
|
new TabSet('Root',
|
||||||
new Tab('Tab1')
|
new Tab('Tab1')
|
||||||
)
|
)
|
||||||
@ -102,7 +102,7 @@ class FieldSetTest extends SapphireTest {
|
|||||||
* Test removing an array of fields from a tab in a set.
|
* Test removing an array of fields from a tab in a set.
|
||||||
*/
|
*/
|
||||||
function testRemoveMultipleFieldsFromTab() {
|
function testRemoveMultipleFieldsFromTab() {
|
||||||
$fields = new FieldSet();
|
$fields = new FieldList();
|
||||||
$tab = new Tab('Root');
|
$tab = new Tab('Root');
|
||||||
$fields->push($tab);
|
$fields->push($tab);
|
||||||
|
|
||||||
@ -131,9 +131,9 @@ class FieldSetTest extends SapphireTest {
|
|||||||
* Test removing a field from a set by it's name.
|
* Test removing a field from a set by it's name.
|
||||||
*/
|
*/
|
||||||
function testRemoveFieldByName() {
|
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'));
|
$fields->push(new TextField('Name', 'Your name'));
|
||||||
|
|
||||||
/* We have 1 field in our set now */
|
/* We have 1 field in our set now */
|
||||||
@ -150,7 +150,7 @@ class FieldSetTest extends SapphireTest {
|
|||||||
* Test replacing a field with another one.
|
* Test replacing a field with another one.
|
||||||
*/
|
*/
|
||||||
function testReplaceField() {
|
function testReplaceField() {
|
||||||
$fields = new FieldSet();
|
$fields = new FieldList();
|
||||||
$tab = new Tab('Root');
|
$tab = new Tab('Root');
|
||||||
$fields->push($tab);
|
$fields->push($tab);
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ class FieldSetTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function testRenameField() {
|
function testRenameField() {
|
||||||
$fields = new FieldSet();
|
$fields = new FieldList();
|
||||||
$nameField = new TextField('Name', 'Before title');
|
$nameField = new TextField('Name', 'Before title');
|
||||||
$fields->push($nameField);
|
$fields->push($nameField);
|
||||||
|
|
||||||
@ -186,8 +186,8 @@ class FieldSetTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function testReplaceAFieldInADifferentTab() {
|
function testReplaceAFieldInADifferentTab() {
|
||||||
/* A FieldSet gets created with a TabSet and some field objects */
|
/* A FieldList gets created with a TabSet and some field objects */
|
||||||
$fieldSet = new FieldSet(
|
$FieldList = new FieldList(
|
||||||
new TabSet('Root', $main = new Tab('Main',
|
new TabSet('Root', $main = new Tab('Main',
|
||||||
new TextField('A'),
|
new TextField('A'),
|
||||||
new TextField('B')
|
new TextField('B')
|
||||||
@ -197,8 +197,8 @@ class FieldSetTest extends SapphireTest {
|
|||||||
))
|
))
|
||||||
);
|
);
|
||||||
|
|
||||||
/* The field "A" gets added to the FieldSet we just created created */
|
/* The field "A" gets added to the FieldList we just created created */
|
||||||
$fieldSet->addFieldToTab('Root.Other', $newA = new TextField('A', 'New Title'));
|
$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. */
|
/* 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());
|
$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.
|
* Test finding a field that's inside a tabset, within another tab.
|
||||||
*/
|
*/
|
||||||
function testNestedTabsFindingFieldByName() {
|
function testNestedTabsFindingFieldByName() {
|
||||||
$fields = new FieldSet();
|
$fields = new FieldList();
|
||||||
|
|
||||||
/* 2 tabs get created within a TabSet inside our set */
|
/* 2 tabs get created within a TabSet inside our set */
|
||||||
$tab = new TabSet('Root',
|
$tab = new TabSet('Root',
|
||||||
@ -241,7 +241,7 @@ class FieldSetTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function testTabTitles() {
|
function testTabTitles() {
|
||||||
$set = new FieldSet(
|
$set = new FieldList(
|
||||||
$rootTabSet = new TabSet('Root',
|
$rootTabSet = new TabSet('Root',
|
||||||
$tabSetWithoutTitle = new TabSet('TabSetWithoutTitle'),
|
$tabSetWithoutTitle = new TabSet('TabSetWithoutTitle'),
|
||||||
$tabSetWithTitle = new TabSet('TabSetWithTitle', 'My TabSet Title',
|
$tabSetWithTitle = new TabSet('TabSetWithTitle', 'My TabSet Title',
|
||||||
@ -281,10 +281,10 @@ class FieldSetTest extends SapphireTest {
|
|||||||
/**
|
/**
|
||||||
* Test pushing a field to a set.
|
* Test pushing a field to a set.
|
||||||
*
|
*
|
||||||
* This tests {@link FieldSet->push()}.
|
* This tests {@link FieldList->push()}.
|
||||||
*/
|
*/
|
||||||
function testPushFieldToSet() {
|
function testPushFieldToSet() {
|
||||||
$fields = new FieldSet();
|
$fields = new FieldList();
|
||||||
|
|
||||||
/* A field named Country is added to the set */
|
/* A field named Country is added to the set */
|
||||||
$fields->push(new TextField('Country'));
|
$fields->push(new TextField('Country'));
|
||||||
@ -310,10 +310,10 @@ class FieldSetTest extends SapphireTest {
|
|||||||
/**
|
/**
|
||||||
* Test inserting a field before another in a set.
|
* Test inserting a field before another in a set.
|
||||||
*
|
*
|
||||||
* This tests {@link FieldSet->insertBefore()}.
|
* This tests {@link FieldList->insertBefore()}.
|
||||||
*/
|
*/
|
||||||
function testInsertBeforeFieldToSet() {
|
function testInsertBeforeFieldToSet() {
|
||||||
$fields = new FieldSet();
|
$fields = new FieldList();
|
||||||
|
|
||||||
/* 3 fields are added to the set */
|
/* 3 fields are added to the set */
|
||||||
$fields->push(new TextField('Country'));
|
$fields->push(new TextField('Country'));
|
||||||
@ -337,7 +337,7 @@ class FieldSetTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function testInsertBeforeMultipleFields() {
|
function testInsertBeforeMultipleFields() {
|
||||||
$fields = new FieldSet(
|
$fields = new FieldList(
|
||||||
$root = new TabSet("Root",
|
$root = new TabSet("Root",
|
||||||
$main = new Tab("Main",
|
$main = new Tab("Main",
|
||||||
$a = new TextField("A"),
|
$a = new TextField("A"),
|
||||||
@ -363,7 +363,7 @@ class FieldSetTest extends SapphireTest {
|
|||||||
* Test inserting a field after another in a set.
|
* Test inserting a field after another in a set.
|
||||||
*/
|
*/
|
||||||
function testInsertAfterFieldToSet() {
|
function testInsertAfterFieldToSet() {
|
||||||
$fields = new FieldSet();
|
$fields = new FieldList();
|
||||||
|
|
||||||
/* 3 fields are added to the set */
|
/* 3 fields are added to the set */
|
||||||
$fields->push(new TextField('Country'));
|
$fields->push(new TextField('Country'));
|
||||||
@ -379,16 +379,16 @@ class FieldSetTest extends SapphireTest {
|
|||||||
/* The field we just added actually exists in the set */
|
/* The field we just added actually exists in the set */
|
||||||
$this->assertNotNull($fields->dataFieldByName('Title'));
|
$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());
|
$this->assertEquals(4, $fields->Count());
|
||||||
|
|
||||||
/* The position of the Title field should be at number 2 */
|
/* The position of the Title field should be at number 2 */
|
||||||
$this->assertEquals('Title', $fields[1]->Name());
|
$this->assertEquals('Title', $fields[1]->Name());
|
||||||
}
|
}
|
||||||
|
|
||||||
function testRootFieldSet() {
|
function testrootFieldSet() {
|
||||||
/* Given a nested set of FormField, CompositeField, and FieldSet objects */
|
/* Given a nested set of FormField, CompositeField, and FieldList objects */
|
||||||
$fieldSet = new FieldSet(
|
$FieldList = new FieldList(
|
||||||
$root = new TabSet("Root",
|
$root = new TabSet("Root",
|
||||||
$main = new Tab("Main",
|
$main = new Tab("Main",
|
||||||
$a = new TextField("A"),
|
$a = new TextField("A"),
|
||||||
@ -397,27 +397,27 @@ class FieldSetTest extends SapphireTest {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
/* rootFieldSet() should always evaluate to the same object: the topmost fieldset */
|
/* rootFieldSet() should always evaluate to the same object: the topmost FieldList */
|
||||||
$this->assertSame($fieldSet, $fieldSet->rootFieldSet());
|
$this->assertSame($FieldList, $FieldList->rootFieldSet());
|
||||||
$this->assertSame($fieldSet, $root->rootFieldSet());
|
$this->assertSame($FieldList, $root->rootFieldSet());
|
||||||
$this->assertSame($fieldSet, $main->rootFieldSet());
|
$this->assertSame($FieldList, $main->rootFieldSet());
|
||||||
$this->assertSame($fieldSet, $a->rootFieldSet());
|
$this->assertSame($FieldList, $a->rootFieldSet());
|
||||||
$this->assertSame($fieldSet, $b->rootFieldSet());
|
$this->assertSame($FieldList, $b->rootFieldSet());
|
||||||
|
|
||||||
/* If we push additional fields, they should also have the same rootFieldSet() */
|
/* If we push additional fields, they should also have the same rootFieldSet() */
|
||||||
$root->push($other = new Tab("Other"));
|
$root->push($other = new Tab("Other"));
|
||||||
$other->push($c = new TextField("C"));
|
$other->push($c = new TextField("C"));
|
||||||
$root->push($third = new Tab("Third", $d = new TextField("D")));
|
$root->push($third = new Tab("Third", $d = new TextField("D")));
|
||||||
|
|
||||||
$this->assertSame($fieldSet, $other->rootFieldSet());
|
$this->assertSame($FieldList, $other->rootFieldSet());
|
||||||
$this->assertSame($fieldSet, $third->rootFieldSet());
|
$this->assertSame($FieldList, $third->rootFieldSet());
|
||||||
$this->assertSame($fieldSet, $c->rootFieldSet());
|
$this->assertSame($FieldList, $c->rootFieldSet());
|
||||||
$this->assertSame($fieldSet, $d->rootFieldSet());
|
$this->assertSame($FieldList, $d->rootFieldSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
function testAddingDuplicateReplacesOldField() {
|
function testAddingDuplicateReplacesOldField() {
|
||||||
/* Given a nested set of FormField, CompositeField, and FieldSet objects */
|
/* Given a nested set of FormField, CompositeField, and FieldList objects */
|
||||||
$fieldSet = new FieldSet(
|
$FieldList = new FieldList(
|
||||||
$root = new TabSet("Root",
|
$root = new TabSet("Root",
|
||||||
$main = new Tab("Main",
|
$main = new Tab("Main",
|
||||||
$a = new TextField("A"),
|
$a = new TextField("A"),
|
||||||
@ -430,27 +430,27 @@ class FieldSetTest extends SapphireTest {
|
|||||||
$newA = new TextField("A", "New A");
|
$newA = new TextField("A", "New A");
|
||||||
$newB = new TextField("B", "New B");
|
$newB = new TextField("B", "New B");
|
||||||
|
|
||||||
$fieldSet->addFieldToTab("Root.Main", $newA);
|
$FieldList->addFieldToTab("Root.Main", $newA);
|
||||||
$fieldSet->addFieldToTab("Root.Other", $newB);
|
$FieldList->addFieldToTab("Root.Other", $newB);
|
||||||
|
|
||||||
$this->assertSame($newA, $fieldSet->dataFieldByName("A"));
|
$this->assertSame($newA, $FieldList->dataFieldByName("A"));
|
||||||
$this->assertSame($newB, $fieldSet->dataFieldByName("B"));
|
$this->assertSame($newB, $FieldList->dataFieldByName("B"));
|
||||||
$this->assertEquals(1, $main->Fields()->Count());
|
$this->assertEquals(1, $main->Fields()->Count());
|
||||||
|
|
||||||
/* Pushing fields on the end of the field set should remove them from the tab */
|
/* Pushing fields on the end of the field set should remove them from the tab */
|
||||||
$thirdA = new TextField("A", "Third A");
|
$thirdA = new TextField("A", "Third A");
|
||||||
$thirdB = new TextField("B", "Third B");
|
$thirdB = new TextField("B", "Third B");
|
||||||
$fieldSet->push($thirdA);
|
$FieldList->push($thirdA);
|
||||||
$fieldSet->push($thirdB);
|
$FieldList->push($thirdB);
|
||||||
|
|
||||||
$this->assertSame($thirdA, $fieldSet->fieldByName("A"));
|
$this->assertSame($thirdA, $FieldList->fieldByName("A"));
|
||||||
$this->assertSame($thirdB, $fieldSet->fieldByName("B"));
|
$this->assertSame($thirdB, $FieldList->fieldByName("B"));
|
||||||
|
|
||||||
$this->assertEquals(0, $main->Fields()->Count());
|
$this->assertEquals(0, $main->Fields()->Count());
|
||||||
}
|
}
|
||||||
|
|
||||||
function testAddingFieldToNonExistentTabCreatesThatTab() {
|
function testAddingFieldToNonExistentTabCreatesThatTab() {
|
||||||
$fieldSet = new FieldSet(
|
$FieldList = new FieldList(
|
||||||
$root = new TabSet("Root",
|
$root = new TabSet("Root",
|
||||||
$main = new Tab("Main",
|
$main = new Tab("Main",
|
||||||
$a = new TextField("A")
|
$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 */
|
/* Add a field to a non-existent tab, and it will be created */
|
||||||
$fieldSet->addFieldToTab("Root.Other", $b = new TextField("B"));
|
$FieldList->addFieldToTab("Root.Other", $b = new TextField("B"));
|
||||||
$this->assertNotNull($fieldSet->fieldByName('Root')->fieldByName('Other'));
|
$this->assertNotNull($FieldList->fieldByName('Root')->fieldByName('Other'));
|
||||||
$this->assertSame($b, $fieldSet->fieldByName('Root')->fieldByName('Other')->Fields()->First());
|
$this->assertSame($b, $FieldList->fieldByName('Root')->fieldByName('Other')->Fields()->First());
|
||||||
}
|
}
|
||||||
|
|
||||||
function testAddingFieldToATabWithTheSameNameAsTheField() {
|
function testAddingFieldToATabWithTheSameNameAsTheField() {
|
||||||
$fieldSet = new FieldSet(
|
$FieldList = new FieldList(
|
||||||
$root = new TabSet("Root",
|
$root = new TabSet("Root",
|
||||||
$main = new Tab("Main",
|
$main = new Tab("Main",
|
||||||
$a = new TextField("A")
|
$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
|
/* 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 */
|
tab isn't a data field. Only duplicate data fields are problematic */
|
||||||
$fieldSet->addFieldToTab("Root.MyName", $myName = new TextField("MyName"));
|
$FieldList->addFieldToTab("Root.MyName", $myName = new TextField("MyName"));
|
||||||
$this->assertNotNull($fieldSet->fieldByName('Root')->fieldByName('MyName'));
|
$this->assertNotNull($FieldList->fieldByName('Root')->fieldByName('MyName'));
|
||||||
$this->assertSame($myName, $fieldSet->fieldByName('Root')->fieldByName('MyName')->Fields()->First());
|
$this->assertSame($myName, $FieldList->fieldByName('Root')->fieldByName('MyName')->Fields()->First());
|
||||||
}
|
}
|
||||||
|
|
||||||
function testInsertBeforeWithNestedCompositeFields() {
|
function testInsertBeforeWithNestedCompositeFields() {
|
||||||
$fieldSet = new FieldSet(
|
$FieldList = new FieldList(
|
||||||
new TextField('A_pre'),
|
new TextField('A_pre'),
|
||||||
new TextField('A'),
|
new TextField('A'),
|
||||||
new TextField('A_post'),
|
new TextField('A_post'),
|
||||||
@ -497,34 +497,34 @@ class FieldSetTest extends SapphireTest {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$fieldSet->insertBefore(
|
$FieldList->insertBefore(
|
||||||
$A_insertbefore = new TextField('A_insertbefore'),
|
$A_insertbefore = new TextField('A_insertbefore'),
|
||||||
'A'
|
'A'
|
||||||
);
|
);
|
||||||
$this->assertSame(
|
$this->assertSame(
|
||||||
$A_insertbefore,
|
$A_insertbefore,
|
||||||
$fieldSet->dataFieldByName('A_insertbefore'),
|
$FieldList->dataFieldByName('A_insertbefore'),
|
||||||
'Field on toplevel fieldset can be inserted'
|
'Field on toplevel FieldList can be inserted'
|
||||||
);
|
);
|
||||||
|
|
||||||
$fieldSet->insertBefore(
|
$FieldList->insertBefore(
|
||||||
$B_insertbefore = new TextField('B_insertbefore'),
|
$B_insertbefore = new TextField('B_insertbefore'),
|
||||||
'B'
|
'B'
|
||||||
);
|
);
|
||||||
$this->assertSame(
|
$this->assertSame(
|
||||||
$fieldSet->dataFieldByName('B_insertbefore'),
|
$FieldList->dataFieldByName('B_insertbefore'),
|
||||||
$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_insertbefore = new TextField('C_insertbefore'),
|
||||||
'C'
|
'C'
|
||||||
);
|
);
|
||||||
$this->assertSame(
|
$this->assertSame(
|
||||||
$fieldSet->dataFieldByName('C_insertbefore'),
|
$FieldList->dataFieldByName('C_insertbefore'),
|
||||||
$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
|
* @todo check actual placement of fields
|
||||||
*/
|
*/
|
||||||
function testInsertBeforeWithNestedTabsets() {
|
function testInsertBeforeWithNestedTabsets() {
|
||||||
$fieldSetA = new FieldSet(
|
$FieldListA = new FieldList(
|
||||||
$tabSetA = new TabSet('TabSet_A',
|
$tabSetA = new TabSet('TabSet_A',
|
||||||
$tabA1 = new Tab('Tab_A1',
|
$tabA1 = new Tab('Tab_A1',
|
||||||
new TextField('A_pre'),
|
new TextField('A_pre'),
|
||||||
@ -549,7 +549,7 @@ class FieldSetTest extends SapphireTest {
|
|||||||
'A'
|
'A'
|
||||||
);
|
);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$fieldSetA->dataFieldByName('A_insertbefore'),
|
$FieldListA->dataFieldByName('A_insertbefore'),
|
||||||
$A_insertbefore,
|
$A_insertbefore,
|
||||||
'Field on toplevel tab can be inserted'
|
'Field on toplevel tab can be inserted'
|
||||||
);
|
);
|
||||||
@ -559,7 +559,7 @@ class FieldSetTest extends SapphireTest {
|
|||||||
$this->assertEquals(2, $tabA1->fieldPosition('A'));
|
$this->assertEquals(2, $tabA1->fieldPosition('A'));
|
||||||
$this->assertEquals(3, $tabA1->fieldPosition('A_post'));
|
$this->assertEquals(3, $tabA1->fieldPosition('A_post'));
|
||||||
|
|
||||||
$fieldSetB = new FieldSet(
|
$FieldListB = new FieldList(
|
||||||
new TabSet('TabSet_A',
|
new TabSet('TabSet_A',
|
||||||
$tabsetB = new TabSet('TabSet_B',
|
$tabsetB = new TabSet('TabSet_B',
|
||||||
$tabB1 = new Tab('Tab_B1',
|
$tabB1 = new Tab('Tab_B1',
|
||||||
@ -573,12 +573,12 @@ class FieldSetTest extends SapphireTest {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$fieldSetB->insertBefore(
|
$FieldListB->insertBefore(
|
||||||
$B_insertbefore = new TextField('B_insertbefore'),
|
$B_insertbefore = new TextField('B_insertbefore'),
|
||||||
'B'
|
'B'
|
||||||
);
|
);
|
||||||
$this->assertSame(
|
$this->assertSame(
|
||||||
$fieldSetB->dataFieldByName('B_insertbefore'),
|
$FieldListB->dataFieldByName('B_insertbefore'),
|
||||||
$B_insertbefore,
|
$B_insertbefore,
|
||||||
'Field on nested tab can be inserted'
|
'Field on nested tab can be inserted'
|
||||||
);
|
);
|
||||||
@ -589,7 +589,7 @@ class FieldSetTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function testInsertAfterWithNestedCompositeFields() {
|
function testInsertAfterWithNestedCompositeFields() {
|
||||||
$fieldSet = new FieldSet(
|
$FieldList = new FieldList(
|
||||||
new TextField('A_pre'),
|
new TextField('A_pre'),
|
||||||
new TextField('A'),
|
new TextField('A'),
|
||||||
new TextField('A_post'),
|
new TextField('A_post'),
|
||||||
@ -605,34 +605,34 @@ class FieldSetTest extends SapphireTest {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$fieldSet->insertAfter(
|
$FieldList->insertAfter(
|
||||||
$A_insertafter = new TextField('A_insertafter'),
|
$A_insertafter = new TextField('A_insertafter'),
|
||||||
'A'
|
'A'
|
||||||
);
|
);
|
||||||
$this->assertSame(
|
$this->assertSame(
|
||||||
$A_insertafter,
|
$A_insertafter,
|
||||||
$fieldSet->dataFieldByName('A_insertafter'),
|
$FieldList->dataFieldByName('A_insertafter'),
|
||||||
'Field on toplevel fieldset can be inserted after'
|
'Field on toplevel FieldList can be inserted after'
|
||||||
);
|
);
|
||||||
|
|
||||||
$fieldSet->insertAfter(
|
$FieldList->insertAfter(
|
||||||
$B_insertafter = new TextField('B_insertafter'),
|
$B_insertafter = new TextField('B_insertafter'),
|
||||||
'B'
|
'B'
|
||||||
);
|
);
|
||||||
$this->assertSame(
|
$this->assertSame(
|
||||||
$fieldSet->dataFieldByName('B_insertafter'),
|
$FieldList->dataFieldByName('B_insertafter'),
|
||||||
$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_insertafter = new TextField('C_insertafter'),
|
||||||
'C'
|
'C'
|
||||||
);
|
);
|
||||||
$this->assertSame(
|
$this->assertSame(
|
||||||
$fieldSet->dataFieldByName('C_insertafter'),
|
$FieldList->dataFieldByName('C_insertafter'),
|
||||||
$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
|
* @todo check actual placement of fields
|
||||||
*/
|
*/
|
||||||
function testInsertAfterWithNestedTabsets() {
|
function testInsertAfterWithNestedTabsets() {
|
||||||
$fieldSetA = new FieldSet(
|
$FieldListA = new FieldList(
|
||||||
$tabSetA = new TabSet('TabSet_A',
|
$tabSetA = new TabSet('TabSet_A',
|
||||||
$tabA1 = new Tab('Tab_A1',
|
$tabA1 = new Tab('Tab_A1',
|
||||||
new TextField('A_pre'),
|
new TextField('A_pre'),
|
||||||
@ -657,7 +657,7 @@ class FieldSetTest extends SapphireTest {
|
|||||||
'A'
|
'A'
|
||||||
);
|
);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$fieldSetA->dataFieldByName('A_insertafter'),
|
$FieldListA->dataFieldByName('A_insertafter'),
|
||||||
$A_insertafter,
|
$A_insertafter,
|
||||||
'Field on toplevel tab can be inserted after'
|
'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(2, $tabA1->fieldPosition('A_insertafter'));
|
||||||
$this->assertEquals(3, $tabA1->fieldPosition('A_post'));
|
$this->assertEquals(3, $tabA1->fieldPosition('A_post'));
|
||||||
|
|
||||||
$fieldSetB = new FieldSet(
|
$FieldListB = new FieldList(
|
||||||
new TabSet('TabSet_A',
|
new TabSet('TabSet_A',
|
||||||
$tabsetB = new TabSet('TabSet_B',
|
$tabsetB = new TabSet('TabSet_B',
|
||||||
$tabB1 = new Tab('Tab_B1',
|
$tabB1 = new Tab('Tab_B1',
|
||||||
@ -680,12 +680,12 @@ class FieldSetTest extends SapphireTest {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$fieldSetB->insertAfter(
|
$FieldListB->insertAfter(
|
||||||
$B_insertafter = new TextField('B_insertafter'),
|
$B_insertafter = new TextField('B_insertafter'),
|
||||||
'B'
|
'B'
|
||||||
);
|
);
|
||||||
$this->assertSame(
|
$this->assertSame(
|
||||||
$fieldSetB->dataFieldByName('B_insertafter'),
|
$FieldListB->dataFieldByName('B_insertafter'),
|
||||||
$B_insertafter,
|
$B_insertafter,
|
||||||
'Field on nested tab can be inserted after'
|
'Field on nested tab can be inserted after'
|
||||||
);
|
);
|
||||||
@ -696,7 +696,7 @@ class FieldSetTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function testFieldPosition() {
|
function testFieldPosition() {
|
||||||
$set = new FieldSet(
|
$set = new FieldList(
|
||||||
new TextField('A'),
|
new TextField('A'),
|
||||||
new TextField('B'),
|
new TextField('B'),
|
||||||
new TextField('C')
|
new TextField('C')
|
||||||
@ -716,17 +716,17 @@ class FieldSetTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function testMakeFieldReadonly() {
|
function testMakeFieldReadonly() {
|
||||||
$fieldSet = new FieldSet(
|
$FieldList = new FieldList(
|
||||||
new TabSet('Root', new Tab('Main',
|
new TabSet('Root', new Tab('Main',
|
||||||
new TextField('A'),
|
new TextField('A'),
|
||||||
new TextField('B')
|
new TextField('B')
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
$fieldSet->makeFieldReadonly('A');
|
$FieldList->makeFieldReadonly('A');
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
$fieldSet->dataFieldByName('A')->isReadonly(),
|
$FieldList->dataFieldByName('A')->isReadonly(),
|
||||||
'Field nested inside a TabSet and FieldSet can be marked readonly by FieldSet->makeFieldReadonly()'
|
'Field nested inside a TabSet and FieldList can be marked readonly by FieldList->makeFieldReadonly()'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,10 +12,10 @@ class FileFieldTest extends FunctionalTest {
|
|||||||
$form = new Form(
|
$form = new Form(
|
||||||
new Controller(),
|
new Controller(),
|
||||||
'Form',
|
'Form',
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
$fileField = new FileField('cv', 'Upload your CV')
|
$fileField = new FileField('cv', 'Upload your CV')
|
||||||
),
|
),
|
||||||
new FieldSet()
|
new FieldList()
|
||||||
);
|
);
|
||||||
$fileFieldValue = array(
|
$fileFieldValue = array(
|
||||||
'name' => 'aCV.txt',
|
'name' => 'aCV.txt',
|
||||||
@ -38,10 +38,10 @@ class FileFieldTest extends FunctionalTest {
|
|||||||
$form = new Form(
|
$form = new Form(
|
||||||
new Controller(),
|
new Controller(),
|
||||||
'Form',
|
'Form',
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
$fileField = new FileField('cv', 'Upload your CV')
|
$fileField = new FileField('cv', 'Upload your CV')
|
||||||
),
|
),
|
||||||
new FieldSet(),
|
new FieldList(),
|
||||||
new RequiredFields('cv')
|
new RequiredFields('cv')
|
||||||
);
|
);
|
||||||
// All fields are filled but for some reason an error occured when uploading the file => fails
|
// All fields are filled but for some reason an error occured when uploading the file => fails
|
||||||
|
@ -20,7 +20,7 @@ class FormScaffolderTest extends SapphireTest {
|
|||||||
|
|
||||||
function testGetCMSFieldsSingleton() {
|
function testGetCMSFieldsSingleton() {
|
||||||
$fields = singleton('FormScaffolderTest_Article')->getCMSFields();
|
$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'));
|
$form->loadDataFrom(singleton('FormScaffolderTest_Article'));
|
||||||
|
|
||||||
$this->assertTrue($fields->hasTabSet(), 'getCMSFields() produces a TabSet');
|
$this->assertTrue($fields->hasTabSet(), 'getCMSFields() produces a TabSet');
|
||||||
@ -34,7 +34,7 @@ class FormScaffolderTest extends SapphireTest {
|
|||||||
$article1 = $this->objFromFixture('FormScaffolderTest_Article', 'article1');
|
$article1 = $this->objFromFixture('FormScaffolderTest_Article', 'article1');
|
||||||
|
|
||||||
$fields = $article1->getCMSFields();
|
$fields = $article1->getCMSFields();
|
||||||
$form = new Form(new Controller(), 'TestForm', $fields, new FieldSet());
|
$form = new Form(new Controller(), 'TestForm', $fields, new FieldList());
|
||||||
$form->loadDataFrom($article1);
|
$form->loadDataFrom($article1);
|
||||||
|
|
||||||
$this->assertNotNull($fields->dataFieldByName('AuthorID'), 'getCMSFields() includes has_one fields on instances');
|
$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');
|
$article1 = $this->objFromFixture('FormScaffolderTest_Article', 'article1');
|
||||||
|
|
||||||
$fields = $article1->getCMSFields();
|
$fields = $article1->getCMSFields();
|
||||||
$form = new Form(new Controller(), 'TestForm', $fields, new FieldSet());
|
$form = new Form(new Controller(), 'TestForm', $fields, new FieldList());
|
||||||
$form->loadDataFrom($article1);
|
$form->loadDataFrom($article1);
|
||||||
|
|
||||||
$this->assertNotNull(
|
$this->assertNotNull(
|
||||||
@ -60,7 +60,7 @@ class FormScaffolderTest extends SapphireTest {
|
|||||||
$fields = $article1->scaffoldFormFields(array(
|
$fields = $article1->scaffoldFormFields(array(
|
||||||
'restrictFields' => array('Title')
|
'restrictFields' => array('Title')
|
||||||
));
|
));
|
||||||
$form = new Form(new Controller(), 'TestForm', $fields, new FieldSet());
|
$form = new Form(new Controller(), 'TestForm', $fields, new FieldList());
|
||||||
$form->loadDataFrom($article1);
|
$form->loadDataFrom($article1);
|
||||||
|
|
||||||
$this->assertNotNull($fields->dataFieldByName('Title'), 'scaffoldCMSFields() includes explitly defined "restrictFields"');
|
$this->assertNotNull($fields->dataFieldByName('Title'), 'scaffoldCMSFields() includes explitly defined "restrictFields"');
|
||||||
@ -73,7 +73,7 @@ class FormScaffolderTest extends SapphireTest {
|
|||||||
$fields = $article1->scaffoldFormFields(array(
|
$fields = $article1->scaffoldFormFields(array(
|
||||||
'fieldClasses' => array('Title' => 'HtmlEditorField')
|
'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);
|
$form->loadDataFrom($article1);
|
||||||
|
|
||||||
$this->assertNotNull(
|
$this->assertNotNull(
|
||||||
@ -88,7 +88,7 @@ class FormScaffolderTest extends SapphireTest {
|
|||||||
|
|
||||||
function testGetFormFields() {
|
function testGetFormFields() {
|
||||||
$fields = singleton('FormScaffolderTest_Article')->getFrontEndFields();
|
$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'));
|
$form->loadDataFrom(singleton('FormScaffolderTest_Article'));
|
||||||
|
|
||||||
$this->assertFalse($fields->hasTabSet(), 'getFrontEndFields() doesnt produce a TabSet by default');
|
$this->assertFalse($fields->hasTabSet(), 'getFrontEndFields() doesnt produce a TabSet by default');
|
||||||
|
@ -16,13 +16,13 @@ class FormTest extends FunctionalTest {
|
|||||||
$form = new Form(
|
$form = new Form(
|
||||||
new Controller(),
|
new Controller(),
|
||||||
'Form',
|
'Form',
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new TextField('key1'),
|
new TextField('key1'),
|
||||||
new TextField('namespace[key2]'),
|
new TextField('namespace[key2]'),
|
||||||
new TextField('namespace[key3][key4]'),
|
new TextField('namespace[key3][key4]'),
|
||||||
new TextField('othernamespace[key5][key6][key7]')
|
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
|
// 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(
|
$form = new Form(
|
||||||
new Controller(),
|
new Controller(),
|
||||||
'Form',
|
'Form',
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new TextField('key1'),
|
new TextField('key1'),
|
||||||
new TextField('key2')
|
new TextField('key2')
|
||||||
),
|
),
|
||||||
new FieldSet()
|
new FieldList()
|
||||||
);
|
);
|
||||||
$form->loadDataFrom(array(
|
$form->loadDataFrom(array(
|
||||||
'key1' => 'save',
|
'key1' => 'save',
|
||||||
@ -81,14 +81,14 @@ class FormTest extends FunctionalTest {
|
|||||||
$form = new Form(
|
$form = new Form(
|
||||||
new Controller(),
|
new Controller(),
|
||||||
'Form',
|
'Form',
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new HeaderField('MyPlayerHeader','My Player'),
|
new HeaderField('MyPlayerHeader','My Player'),
|
||||||
new TextField('Name'), // appears in both Player and Team
|
new TextField('Name'), // appears in both Player and Team
|
||||||
new TextareaField('Biography'),
|
new TextareaField('Biography'),
|
||||||
new DateField('Birthday'),
|
new DateField('Birthday'),
|
||||||
new NumericField('BirthdayYear') // dynamic property
|
new NumericField('BirthdayYear') // dynamic property
|
||||||
),
|
),
|
||||||
new FieldSet()
|
new FieldList()
|
||||||
);
|
);
|
||||||
|
|
||||||
$captainWithDetails = $this->objFromFixture('FormTest_Player', 'captainWithDetails');
|
$captainWithDetails = $this->objFromFixture('FormTest_Player', 'captainWithDetails');
|
||||||
@ -122,7 +122,7 @@ class FormTest extends FunctionalTest {
|
|||||||
$form = new Form(
|
$form = new Form(
|
||||||
new Controller(),
|
new Controller(),
|
||||||
'Form',
|
'Form',
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new HeaderField('MyPlayerHeader','My Player'),
|
new HeaderField('MyPlayerHeader','My Player'),
|
||||||
new TextField('Name'), // appears in both Player and Team
|
new TextField('Name'), // appears in both Player and Team
|
||||||
new TextareaField('Biography'),
|
new TextareaField('Biography'),
|
||||||
@ -131,7 +131,7 @@ class FormTest extends FunctionalTest {
|
|||||||
$unrelatedField = new TextField('UnrelatedFormField')
|
$unrelatedField = new TextField('UnrelatedFormField')
|
||||||
//new CheckboxSetField('Teams') // relation editing
|
//new CheckboxSetField('Teams') // relation editing
|
||||||
),
|
),
|
||||||
new FieldSet()
|
new FieldList()
|
||||||
);
|
);
|
||||||
$unrelatedField->setValue("random value");
|
$unrelatedField->setValue("random value");
|
||||||
|
|
||||||
@ -329,8 +329,8 @@ class FormTest extends FunctionalTest {
|
|||||||
return new Form(
|
return new Form(
|
||||||
new Controller(),
|
new Controller(),
|
||||||
'Form',
|
'Form',
|
||||||
new FieldSet(new TextField('key1')),
|
new FieldList(new TextField('key1')),
|
||||||
new FieldSet()
|
new FieldList()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -383,12 +383,12 @@ class FormTest_Controller extends Controller implements TestOnly {
|
|||||||
$form = new Form(
|
$form = new Form(
|
||||||
$this,
|
$this,
|
||||||
'Form',
|
'Form',
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new EmailField('Email'),
|
new EmailField('Email'),
|
||||||
new TextField('SomeRequiredField'),
|
new TextField('SomeRequiredField'),
|
||||||
new CheckboxSetField('Boxes', null, array('1'=>'one','2'=>'two'))
|
new CheckboxSetField('Boxes', null, array('1'=>'one','2'=>'two'))
|
||||||
),
|
),
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new FormAction('doSubmit')
|
new FormAction('doSubmit')
|
||||||
),
|
),
|
||||||
new RequiredFields(
|
new RequiredFields(
|
||||||
@ -407,10 +407,10 @@ class FormTest_Controller extends Controller implements TestOnly {
|
|||||||
$form = new Form(
|
$form = new Form(
|
||||||
$this,
|
$this,
|
||||||
'FormWithSecurityToken',
|
'FormWithSecurityToken',
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new EmailField('Email')
|
new EmailField('Email')
|
||||||
),
|
),
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new FormAction('doSubmit')
|
new FormAction('doSubmit')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -444,10 +444,10 @@ class FormTest_ControllerWithSecurityToken extends Controller implements TestOnl
|
|||||||
$form = new Form(
|
$form = new Form(
|
||||||
$this,
|
$this,
|
||||||
'Form',
|
'Form',
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new EmailField('Email')
|
new EmailField('Email')
|
||||||
),
|
),
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new FormAction('doSubmit')
|
new FormAction('doSubmit')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -45,7 +45,7 @@ class MemberDatetimeOptionsetFieldTest extends SapphireTest {
|
|||||||
|
|
||||||
function testDateFormatDefaultCheckedInFormField() {
|
function testDateFormatDefaultCheckedInFormField() {
|
||||||
$field = $this->createDateFormatFieldForMember($this->objFromFixture('Member', 'noformatmember'));
|
$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());
|
$parser = new CSSContentParser($field->Field());
|
||||||
$xmlArr = $parser->getBySelector('#Form_Form_DateFormat_MM_dd_yyyy');
|
$xmlArr = $parser->getBySelector('#Form_Form_DateFormat_MM_dd_yyyy');
|
||||||
$this->assertEquals('checked', (string) $xmlArr[0]['checked']);
|
$this->assertEquals('checked', (string) $xmlArr[0]['checked']);
|
||||||
@ -53,7 +53,7 @@ class MemberDatetimeOptionsetFieldTest extends SapphireTest {
|
|||||||
|
|
||||||
function testTimeFormatDefaultCheckedInFormField() {
|
function testTimeFormatDefaultCheckedInFormField() {
|
||||||
$field = $this->createTimeFormatFieldForMember($this->objFromFixture('Member', 'noformatmember'));
|
$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());
|
$parser = new CSSContentParser($field->Field());
|
||||||
$xmlArr = $parser->getBySelector('#Form_Form_TimeFormat_hh_mm_a');
|
$xmlArr = $parser->getBySelector('#Form_Form_TimeFormat_hh_mm_a');
|
||||||
$this->assertEquals('checked', (string) $xmlArr[0]['checked']);
|
$this->assertEquals('checked', (string) $xmlArr[0]['checked']);
|
||||||
@ -63,7 +63,7 @@ class MemberDatetimeOptionsetFieldTest extends SapphireTest {
|
|||||||
$member = $this->objFromFixture('Member', 'noformatmember');
|
$member = $this->objFromFixture('Member', 'noformatmember');
|
||||||
$member->setField('DateFormat', 'MM/dd/yyyy');
|
$member->setField('DateFormat', 'MM/dd/yyyy');
|
||||||
$field = $this->createDateFormatFieldForMember($member);
|
$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());
|
$parser = new CSSContentParser($field->Field());
|
||||||
$xmlArr = $parser->getBySelector('#Form_Form_DateFormat_MM_dd_yyyy');
|
$xmlArr = $parser->getBySelector('#Form_Form_DateFormat_MM_dd_yyyy');
|
||||||
$this->assertEquals('checked', (string) $xmlArr[0]['checked']);
|
$this->assertEquals('checked', (string) $xmlArr[0]['checked']);
|
||||||
@ -73,7 +73,7 @@ class MemberDatetimeOptionsetFieldTest extends SapphireTest {
|
|||||||
$member = $this->objFromFixture('Member', 'noformatmember');
|
$member = $this->objFromFixture('Member', 'noformatmember');
|
||||||
$member->setField('DateFormat', 'dd MM yy');
|
$member->setField('DateFormat', 'dd MM yy');
|
||||||
$field = $this->createDateFormatFieldForMember($member);
|
$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());
|
$parser = new CSSContentParser($field->Field());
|
||||||
$xmlInputArr = $parser->getBySelector('.valCustom input');
|
$xmlInputArr = $parser->getBySelector('.valCustom input');
|
||||||
$xmlPreview = $parser->getBySelector('.preview');
|
$xmlPreview = $parser->getBySelector('.preview');
|
||||||
|
@ -28,8 +28,8 @@ class TableFieldTest extends SapphireTest {
|
|||||||
$form = new Form(
|
$form = new Form(
|
||||||
new TableFieldTest_Controller(),
|
new TableFieldTest_Controller(),
|
||||||
"Form",
|
"Form",
|
||||||
new FieldSet($tableField),
|
new FieldList($tableField),
|
||||||
new FieldSet()
|
new FieldList()
|
||||||
);
|
);
|
||||||
|
|
||||||
// Test Insert
|
// Test Insert
|
||||||
@ -106,8 +106,8 @@ class TableFieldTest extends SapphireTest {
|
|||||||
$form = new Form(
|
$form = new Form(
|
||||||
new TableFieldTest_Controller(),
|
new TableFieldTest_Controller(),
|
||||||
"Form",
|
"Form",
|
||||||
new FieldSet($tableField),
|
new FieldList($tableField),
|
||||||
new FieldSet()
|
new FieldList()
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(2, $tableField->sourceItems()->Count());
|
$this->assertEquals(2, $tableField->sourceItems()->Count());
|
||||||
@ -155,8 +155,8 @@ class TableFieldTest extends SapphireTest {
|
|||||||
$form = new Form(
|
$form = new Form(
|
||||||
new TableFieldTest_Controller(),
|
new TableFieldTest_Controller(),
|
||||||
"Form",
|
"Form",
|
||||||
new FieldSet($tableField),
|
new FieldList($tableField),
|
||||||
new FieldSet()
|
new FieldList()
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertContains($perm1->ID, $tableField->sourceItems()->column('ID'));
|
$this->assertContains($perm1->ID, $tableField->sourceItems()->column('ID'));
|
||||||
@ -185,7 +185,7 @@ class TableFieldTest extends SapphireTest {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Test with auto relation setting
|
// 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);
|
$form->loadDataFrom($o);
|
||||||
|
|
||||||
$tf->setValue(array(
|
$tf->setValue(array(
|
||||||
|
@ -17,9 +17,9 @@ class TableListFieldTest extends SapphireTest {
|
|||||||
"E" => "Col E",
|
"E" => "Col E",
|
||||||
));
|
));
|
||||||
// A TableListField must be inside a form for its links to be generated
|
// 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
|
$table
|
||||||
), new FieldSet());
|
), new FieldList());
|
||||||
|
|
||||||
$result = $table->FieldHolder();
|
$result = $table->FieldHolder();
|
||||||
|
|
||||||
@ -45,9 +45,9 @@ class TableListFieldTest extends SapphireTest {
|
|||||||
"E" => "Col E",
|
"E" => "Col E",
|
||||||
));
|
));
|
||||||
// A TableListField must be inside a form for its links to be generated
|
// 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
|
$table
|
||||||
), new FieldSet());
|
), new FieldList());
|
||||||
|
|
||||||
$items = $table->sourceItems();
|
$items = $table->sourceItems();
|
||||||
$this->assertNotNull($items);
|
$this->assertNotNull($items);
|
||||||
@ -78,9 +78,9 @@ class TableListFieldTest extends SapphireTest {
|
|||||||
"E" => "Col E",
|
"E" => "Col E",
|
||||||
));
|
));
|
||||||
// A TableListField must be inside a form for its links to be generated
|
// 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
|
$table
|
||||||
), new FieldSet());
|
), new FieldList());
|
||||||
|
|
||||||
$table->ShowPagination = true;
|
$table->ShowPagination = true;
|
||||||
$table->PageSize = 2;
|
$table->PageSize = 2;
|
||||||
@ -111,9 +111,9 @@ class TableListFieldTest extends SapphireTest {
|
|||||||
"E" => "Col E",
|
"E" => "Col E",
|
||||||
));
|
));
|
||||||
// A TableListField must be inside a form for its links to be generated
|
// 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
|
$table
|
||||||
), new FieldSet());
|
), new FieldList());
|
||||||
|
|
||||||
$table->ShowPagination = true;
|
$table->ShowPagination = true;
|
||||||
$table->PageSize = 2;
|
$table->PageSize = 2;
|
||||||
@ -182,9 +182,9 @@ class TableListFieldTest extends SapphireTest {
|
|||||||
"B" => "Col B"
|
"B" => "Col B"
|
||||||
));
|
));
|
||||||
|
|
||||||
$form = new Form(new TableListFieldTest_TestController(), "TestForm", new FieldSet(
|
$form = new Form(new TableListFieldTest_TestController(), "TestForm", new FieldList(
|
||||||
$table
|
$table
|
||||||
), new FieldSet());
|
), new FieldList());
|
||||||
|
|
||||||
$csvResponse = $table->export();
|
$csvResponse = $table->export();
|
||||||
|
|
||||||
@ -219,7 +219,7 @@ class TableListFieldTest extends SapphireTest {
|
|||||||
|
|
||||||
function testLink() {
|
function testLink() {
|
||||||
// A TableListField must be inside a form for its links to be generated
|
// 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(
|
new TableListField("Tester", "TableListFieldTest_Obj", array(
|
||||||
"A" => "Col A",
|
"A" => "Col A",
|
||||||
"B" => "Col B",
|
"B" => "Col B",
|
||||||
@ -227,7 +227,7 @@ class TableListFieldTest extends SapphireTest {
|
|||||||
"D" => "Col D",
|
"D" => "Col D",
|
||||||
"E" => "Col E",
|
"E" => "Col E",
|
||||||
))
|
))
|
||||||
), new FieldSet());
|
), new FieldList());
|
||||||
|
|
||||||
$table = $form->dataFieldByName('Tester');
|
$table = $form->dataFieldByName('Tester');
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
@ -252,9 +252,9 @@ class TableListFieldTest extends SapphireTest {
|
|||||||
"E" => "Col E",
|
"E" => "Col E",
|
||||||
));
|
));
|
||||||
// A TableListField must be inside a form for its links to be generated
|
// 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
|
$table
|
||||||
), new FieldSet());
|
), new FieldList());
|
||||||
|
|
||||||
$table->ShowPagination = true;
|
$table->ShowPagination = true;
|
||||||
$table->PageSize = 2;
|
$table->PageSize = 2;
|
||||||
@ -307,7 +307,7 @@ class TableListFieldTest extends SapphireTest {
|
|||||||
$list = new ArrayList(array($one, $two, $three));
|
$list = new ArrayList(array($one, $two, $three));
|
||||||
|
|
||||||
// A TableListField must be inside a form for its links to be generated
|
// 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(
|
new TableListField("Tester", $list, array(
|
||||||
"A" => "Col A",
|
"A" => "Col A",
|
||||||
"B" => "Col B",
|
"B" => "Col B",
|
||||||
@ -315,7 +315,7 @@ class TableListFieldTest extends SapphireTest {
|
|||||||
"D" => "Col D",
|
"D" => "Col D",
|
||||||
"E" => "Col E",
|
"E" => "Col E",
|
||||||
))
|
))
|
||||||
), new FieldSet());
|
), new FieldList());
|
||||||
|
|
||||||
$table = $form->dataFieldByName('Tester');
|
$table = $form->dataFieldByName('Tester');
|
||||||
$rendered = $table->FieldHolder();
|
$rendered = $table->FieldHolder();
|
||||||
@ -367,8 +367,8 @@ class TableListFieldTest_TestController extends Controller {
|
|||||||
$table->disableSorting();
|
$table->disableSorting();
|
||||||
|
|
||||||
// A TableListField must be inside a form for its links to be generated
|
// 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
|
$table
|
||||||
), new FieldSet());
|
), new FieldList());
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -85,7 +85,7 @@ class SearchContextTest extends SapphireTest {
|
|||||||
$context = $company->getDefaultSearchContext();
|
$context = $company->getDefaultSearchContext();
|
||||||
$fields = $context->getFields();
|
$fields = $context->getFields();
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new TextField("Name", 'Name'),
|
new TextField("Name", 'Name'),
|
||||||
new TextareaField("Industry", 'Industry'),
|
new TextareaField("Industry", 'Industry'),
|
||||||
new NumericField("AnnualProfit", 'The Almighty Annual Profit')
|
new NumericField("AnnualProfit", 'The Almighty Annual Profit')
|
||||||
|
@ -129,7 +129,7 @@ class GroupTest_Member extends Member implements TestOnly {
|
|||||||
function getCMSFields() {
|
function getCMSFields() {
|
||||||
$groups = DataObject::get('Group');
|
$groups = DataObject::get('Group');
|
||||||
$groupsMap = ($groups) ? $groups->map() : false;
|
$groupsMap = ($groups) ? $groups->map() : false;
|
||||||
$fields = new FieldSet(
|
$fields = new FieldList(
|
||||||
new HiddenField('ID', 'ID'),
|
new HiddenField('ID', 'ID'),
|
||||||
new CheckboxSetField(
|
new CheckboxSetField(
|
||||||
'Groups',
|
'Groups',
|
||||||
@ -147,7 +147,7 @@ class GroupTest_MemberForm extends Form {
|
|||||||
|
|
||||||
function __construct($controller, $name) {
|
function __construct($controller, $name) {
|
||||||
$fields = singleton('GroupTest_Member')->getCMSFields();
|
$fields = singleton('GroupTest_Member')->getCMSFields();
|
||||||
$actions = new FieldSet(
|
$actions = new FieldList(
|
||||||
new FormAction('doSave','save')
|
new FormAction('doSave','save')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ class SecurityTokenTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function testUpdateFieldSet() {
|
function testUpdateFieldSet() {
|
||||||
$fs = new FieldSet();
|
$fs = new FieldList();
|
||||||
$t = new SecurityToken();
|
$t = new SecurityToken();
|
||||||
$t->updateFieldSet($fs);
|
$t->updateFieldSet($fs);
|
||||||
$f = $fs->dataFieldByName($t->getName());
|
$f = $fs->dataFieldByName($t->getName());
|
||||||
@ -117,7 +117,7 @@ class SecurityTokenTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function testUpdateFieldSetDoesntAddTwice() {
|
function testUpdateFieldSetDoesntAddTwice() {
|
||||||
$fs = new FieldSet();
|
$fs = new FieldList();
|
||||||
$t = new SecurityToken();
|
$t = new SecurityToken();
|
||||||
$t->updateFieldSet($fs); // first
|
$t->updateFieldSet($fs); // first
|
||||||
$t->updateFieldSet($fs); // second
|
$t->updateFieldSet($fs); // second
|
||||||
|
Loading…
Reference in New Issue
Block a user