mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MINOR: Replace references to FieldSet (now deprecated) with references to FieldList
This commit is contained in:
parent
4c0105a3c4
commit
0a3e0f15de
@ -135,7 +135,7 @@ abstract class CMSBatchAction extends Object {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// if your batchaction has parameters, return a fieldset here
|
// if your batchaction has parameters, return a FieldList here
|
||||||
function getParameterFields() {
|
function getParameterFields() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -786,7 +786,7 @@ class LeftAndMain extends Controller {
|
|||||||
$fields = ($fields) ? $fields : $record->getCMSFields();
|
$fields = ($fields) ? $fields : $record->getCMSFields();
|
||||||
if ($fields == null) {
|
if ($fields == null) {
|
||||||
user_error(
|
user_error(
|
||||||
"getCMSFields() returned null - it should return a FieldSet object.
|
"getCMSFields() returned null - it should return a FieldList object.
|
||||||
Perhaps you forgot to put a return statement at the end of your method?",
|
Perhaps you forgot to put a return statement at the end of your method?",
|
||||||
E_USER_ERROR
|
E_USER_ERROR
|
||||||
);
|
);
|
||||||
|
@ -100,7 +100,7 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return FieldSet
|
* @return FieldList
|
||||||
*/
|
*/
|
||||||
function RootForm() {
|
function RootForm() {
|
||||||
$memberList = new MemberTableField(
|
$memberList = new MemberTableField(
|
||||||
|
@ -182,7 +182,7 @@ abstract class BulkLoader extends ViewableData {
|
|||||||
abstract protected function processRecord($record, $columnMap, &$result, $preview = false);
|
abstract protected function processRecord($record, $columnMap, &$result, $preview = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a FieldSet containing all the options for this form; this
|
* Return a FieldList containing all the options for this form; this
|
||||||
* doesn't include the actual upload field itself
|
* doesn't include the actual upload field itself
|
||||||
*/
|
*/
|
||||||
public function getOptionFields() {}
|
public function getOptionFields() {}
|
||||||
|
@ -78,10 +78,10 @@ You can have more customized logic and interface feedback through a custom contr
|
|||||||
$form = new Form(
|
$form = new Form(
|
||||||
$this,
|
$this,
|
||||||
'Form',
|
'Form',
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new FileField('CsvFile', false)
|
new FileField('CsvFile', false)
|
||||||
),
|
),
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new FormAction('doUpload', 'Upload')
|
new FormAction('doUpload', 'Upload')
|
||||||
),
|
),
|
||||||
new RequiredFields()
|
new RequiredFields()
|
||||||
|
@ -43,7 +43,7 @@ You can override this behaviour in various ways:
|
|||||||
'MyName',
|
'MyName',
|
||||||
'Product',
|
'Product',
|
||||||
array('Price','Code'),
|
array('Price','Code'),
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new TextField('Price')
|
new TextField('Price')
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -75,11 +75,11 @@ popup as there is more real-estate for you to play with.
|
|||||||
|
|
||||||
`[api:ComplexTableField]` gives you several options to do this. You can either
|
`[api:ComplexTableField]` gives you several options to do this. You can either
|
||||||
|
|
||||||
* Pass a FieldSet in the constructor.
|
* Pass a FieldList in the constructor.
|
||||||
* Pass a String in the constructor.
|
* Pass a String in the constructor.
|
||||||
|
|
||||||
The first will simply add the fieldset to the form, and populate it with the source class.
|
The first will simply add the fieldlist to the form, and populate it with the source class.
|
||||||
The second will call the String as a method on the source class (Which should return a FieldSet) of fields for the
|
The second will call the String as a method on the source class (Which should return a FieldList) of fields for the
|
||||||
Popup.
|
Popup.
|
||||||
|
|
||||||
You can also customise Javascript which is loaded for the Lightbox. As Requirements::clear() is called when the popup is
|
You can also customise Javascript which is loaded for the Lightbox. As Requirements::clear() is called when the popup is
|
||||||
@ -108,7 +108,7 @@ You'll have to do something like this in your form:
|
|||||||
|
|
||||||
$tableField->setParentClass(false);
|
$tableField->setParentClass(false);
|
||||||
|
|
||||||
$fields = new FieldSet(
|
$fields = new FieldList(
|
||||||
new HiddenField('ID', ''),
|
new HiddenField('ID', ''),
|
||||||
$tableField
|
$tableField
|
||||||
);
|
);
|
||||||
|
@ -88,7 +88,7 @@ extension:
|
|||||||
The $fields parameter is passed by reference, as it is an object.
|
The $fields parameter is passed by reference, as it is an object.
|
||||||
|
|
||||||
:::php
|
:::php
|
||||||
public function updateCMSFields(FieldSet $fields) {
|
public function updateCMSFields(FieldList $fields) {
|
||||||
$fields->push(new TextField('Position', 'Position Title'));
|
$fields->push(new TextField('Position', 'Position Title'));
|
||||||
$fields->push(new ImageField('Image', 'Profile Image'));
|
$fields->push(new ImageField('Image', 'Profile Image'));
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ A single database record & abstract class for the data-access-model.
|
|||||||
## Basics
|
## Basics
|
||||||
|
|
||||||
The call to `DataObject->getCMSFields()` is the centerpiece of every data administration interface in SilverStripe,
|
The call to `DataObject->getCMSFields()` is the centerpiece of every data administration interface in SilverStripe,
|
||||||
which returns a `[api:FieldSet]`''.
|
which returns a `[api:FieldList]`''.
|
||||||
|
|
||||||
:::php
|
:::php
|
||||||
class MyPage extends Page {
|
class MyPage extends Page {
|
||||||
@ -27,7 +27,7 @@ which returns a `[api:FieldSet]`''.
|
|||||||
|
|
||||||
## Scaffolding Formfields
|
## Scaffolding Formfields
|
||||||
|
|
||||||
These calls retrieve a `[api:FieldSet]` for the area where you intend to work with the scaffolded form.
|
These calls retrieve a `[api:FieldList]` for the area where you intend to work with the scaffolded form.
|
||||||
|
|
||||||
### For the CMS
|
### For the CMS
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ given set of fields in a given set of tables
|
|||||||
* `[CompositeField](api:CompositeField)`: Base class for all fields that contain other fields. Uses `<div>` in template, but
|
* `[CompositeField](api:CompositeField)`: Base class for all fields that contain other fields. Uses `<div>` in template, but
|
||||||
doesn't necessarily have any visible styling.
|
doesn't necessarily have any visible styling.
|
||||||
* `[FieldGroup](api:FieldGroup)`: Same as CompositeField, but has default styling (indentation) attached in CMS-context.
|
* `[FieldGroup](api:FieldGroup)`: Same as CompositeField, but has default styling (indentation) attached in CMS-context.
|
||||||
* `[api:FieldSet]`: Basic container for sequential fields, or nested fields through CompositeField. Does NOT render a
|
* `[api:FieldList]`: Basic container for sequential fields, or nested fields through CompositeField. Does NOT render a
|
||||||
`<fieldgroup>`.
|
`<fieldgroup>`.
|
||||||
* `[TabSet](api:TabSet)`
|
* `[TabSet](api:TabSet)`
|
||||||
* `[Tab](api:Tab)`
|
* `[Tab](api:Tab)`
|
||||||
|
@ -51,10 +51,10 @@ The PHP file defining your new subclass is the first step in the process. This
|
|||||||
*/
|
*/
|
||||||
public function getEditForm($id = null) {
|
public function getEditForm($id = null) {
|
||||||
return new Form($this, "EditForm",
|
return new Form($this, "EditForm",
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new ReadonlyField('id #',$id)
|
new ReadonlyField('id #',$id)
|
||||||
),
|
),
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new FormAction('go')
|
new FormAction('go')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -64,8 +64,8 @@ Note that if you want to look this class-name up, you can call Object::getCustom
|
|||||||
## Overloading getCMSFields()
|
## Overloading getCMSFields()
|
||||||
|
|
||||||
If you overload the built-in function getCMSFields(), then you can change the form that is used to view & edit member
|
If you overload the built-in function getCMSFields(), then you can change the form that is used to view & edit member
|
||||||
details in the newsletter system. This function returns a `[api:FieldSet]` object. You should generally start by calling
|
details in the newsletter system. This function returns a `[api:FieldList]` object. You should generally start by calling
|
||||||
parent::getCMSFields() and manipulate the `[api:FieldSet]` from there.
|
parent::getCMSFields() and manipulate the `[api:FieldList]` from there.
|
||||||
|
|
||||||
:::php
|
:::php
|
||||||
function getCMSFields() {
|
function getCMSFields() {
|
||||||
@ -106,10 +106,10 @@ things, you should add appropriate `[api:Permission::checkMember()]` calls to th
|
|||||||
|
|
||||||
* Modify the field set to be displayed in the CMS detail pop-up
|
* Modify the field set to be displayed in the CMS detail pop-up
|
||||||
*/
|
*/
|
||||||
function updateCMSFields(FieldSet $currentFields) {
|
function updateCMSFields(FieldList $currentFields) {
|
||||||
// Only show the additional fields on an appropriate kind of use
|
// Only show the additional fields on an appropriate kind of use
|
||||||
if(Permission::checkMember($this->owner->ID, "VIEW_FORUM")) {
|
if(Permission::checkMember($this->owner->ID, "VIEW_FORUM")) {
|
||||||
// Edit the fieldset passed, adding or removing fields as necessary
|
// Edit the FieldList passed, adding or removing fields as necessary
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ it just receives a set of search parameters and an object class it acts on.
|
|||||||
The default output of a `[api:SearchContext]` is either a `[api:SQLQuery]` object for further refinement, or a
|
The default output of a `[api:SearchContext]` is either a `[api:SQLQuery]` object for further refinement, or a
|
||||||
`[api:DataObject]` instance.
|
`[api:DataObject]` instance.
|
||||||
|
|
||||||
In case you need multiple contexts, consider namespacing your request parameters by using `FieldSet->namespace()` on
|
In case you need multiple contexts, consider namespacing your request parameters by using `FieldList->namespace()` on
|
||||||
the $fields constructor parameter.
|
the $fields constructor parameter.
|
||||||
|
|
||||||
`[api:SearchContext]` is mainly used by `[api:ModelAdmin]`, our generic data administration interface. Another
|
`[api:SearchContext]` is mainly used by `[api:ModelAdmin]`, our generic data administration interface. Another
|
||||||
@ -71,7 +71,7 @@ method, we're building our own `getCustomSearchContext()` variant.
|
|||||||
$fields = $context->getSearchFields();
|
$fields = $context->getSearchFields();
|
||||||
$form = new Form($this, "SearchForm",
|
$form = new Form($this, "SearchForm",
|
||||||
$fields,
|
$fields,
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new FormAction('doSearch')
|
new FormAction('doSearch')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -47,7 +47,7 @@ Create a mysite/code/CustomSiteConfig.php file.
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateCMSFields(FieldSet $fields) {
|
public function updateCMSFields(FieldList $fields) {
|
||||||
$fields->addFieldToTab("Root.Main", new HTMLEditorField("FooterContent", "Footer Content"));
|
$fields->addFieldToTab("Root.Main", new HTMLEditorField("FooterContent", "Footer Content"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,11 +14,11 @@ class.
|
|||||||
:::php
|
:::php
|
||||||
function Form() {
|
function Form() {
|
||||||
$form = new Form($this, 'Form',
|
$form = new Form($this, 'Form',
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new TextField('MyRequiredField'),
|
new TextField('MyRequiredField'),
|
||||||
new TextField('MyOptionalField')
|
new TextField('MyOptionalField')
|
||||||
),
|
),
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new FormAction('submit', 'Submit')
|
new FormAction('submit', 'Submit')
|
||||||
),
|
),
|
||||||
new RequiredFields(array('MyRequiredField'))
|
new RequiredFields(array('MyRequiredField'))
|
||||||
|
@ -14,19 +14,19 @@ constructor takes the following arguments:
|
|||||||
* `$name`: This must be the name of the method on that controller that is called to return the form. The first two
|
* `$name`: This must be the name of the method on that controller that is called to return the form. The first two
|
||||||
fields allow the form object to be re-created after submission. **It's vital that they are properly set - if you ever
|
fields allow the form object to be re-created after submission. **It's vital that they are properly set - if you ever
|
||||||
have problems with form action handler not working, check that these values are correct.**
|
have problems with form action handler not working, check that these values are correct.**
|
||||||
* `$fields`: A `[api:FieldSet]` containing `[api:FormField]` instances make up fields in the form.
|
* `$fields`: A `[api:FieldList]` containing `[api:FormField]` instances make up fields in the form.
|
||||||
* `$actions`: A `[api:FieldSet]` containing the `[api:FormAction]` objects - the buttons at the bottom.
|
* `$actions`: A `[api:FieldList]` containing the `[api:FormAction]` objects - the buttons at the bottom.
|
||||||
* `$validator`: An optional `[api:Validator]` for more information.
|
* `$validator`: An optional `[api:Validator]` for more information.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
:::php
|
:::php
|
||||||
function MyCustomForm() {
|
function MyCustomForm() {
|
||||||
$fields = new FieldSet(
|
$fields = new FieldList(
|
||||||
new EmailField("Email"),
|
new EmailField("Email"),
|
||||||
new EncryptField("Password")
|
new EncryptField("Password")
|
||||||
);
|
);
|
||||||
$actions = new FieldSet(new FormAction("login", "Log in"));
|
$actions = new FieldList(new FormAction("login", "Log in"));
|
||||||
return new Form($this, "MyCustomForm", $fields, $actions);
|
return new Form($this, "MyCustomForm", $fields, $actions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,11 +44,11 @@ $name must be passed - their values depend on where the form is instantiated.
|
|||||||
:::php
|
:::php
|
||||||
class MyForm extends Form {
|
class MyForm extends Form {
|
||||||
function __construct($controller, $name) {
|
function __construct($controller, $name) {
|
||||||
$fields = new FieldSet(
|
$fields = new FieldList(
|
||||||
new EmailField("Email"),
|
new EmailField("Email"),
|
||||||
new EncryptedField("Password")
|
new EncryptedField("Password")
|
||||||
);
|
);
|
||||||
$actions = new FieldSet(new FormAction("login", "Log in"));
|
$actions = new FieldList(new FormAction("login", "Log in"));
|
||||||
|
|
||||||
parent::__construct($controller, $name, $fields, $actions);
|
parent::__construct($controller, $name, $fields, $actions);
|
||||||
}
|
}
|
||||||
@ -77,13 +77,13 @@ Full overview at [form-field-types](/reference/form-field-types)
|
|||||||
### Using Form Fields
|
### Using Form Fields
|
||||||
|
|
||||||
To get these fields automatically rendered into a form element, all you need to do is create a new instance of the
|
To get these fields automatically rendered into a form element, all you need to do is create a new instance of the
|
||||||
class, and add it to the fieldset of the form.
|
class, and add it to the fieldlist of the form.
|
||||||
|
|
||||||
:::php
|
:::php
|
||||||
$form = new Form(
|
$form = new Form(
|
||||||
$controller = $this,
|
$controller = $this,
|
||||||
$name = "SignupForm",
|
$name = "SignupForm",
|
||||||
$fields = new FieldSet(
|
$fields = new FieldList(
|
||||||
new TextField(
|
new TextField(
|
||||||
$name = "FirstName",
|
$name = "FirstName",
|
||||||
$title = "First name"
|
$title = "First name"
|
||||||
@ -91,7 +91,7 @@ class, and add it to the fieldset of the form.
|
|||||||
new TextField("Surname"),
|
new TextField("Surname"),
|
||||||
new EmailField("Email", "Email address"),
|
new EmailField("Email", "Email address"),
|
||||||
),
|
),
|
||||||
$actions = new FieldSet(
|
$actions = new FieldList(
|
||||||
// List the action buttons here
|
// List the action buttons here
|
||||||
new FormAction("signup", "Sign up")
|
new FormAction("signup", "Sign up")
|
||||||
),
|
),
|
||||||
@ -109,7 +109,7 @@ Implementing the more complex fields requires extra arguments.
|
|||||||
$form = new Form(
|
$form = new Form(
|
||||||
$controller = $this,
|
$controller = $this,
|
||||||
$name = "SignupForm",
|
$name = "SignupForm",
|
||||||
$fields = new FieldSet(
|
$fields = new FieldList(
|
||||||
// List the your fields here
|
// List the your fields here
|
||||||
new TextField(
|
new TextField(
|
||||||
$name = "FirstName",
|
$name = "FirstName",
|
||||||
@ -123,7 +123,7 @@ Implementing the more complex fields requires extra arguments.
|
|||||||
$source = Geoip::getCountryDropDown(),
|
$source = Geoip::getCountryDropDown(),
|
||||||
$value = Geoip::visitor_country()
|
$value = Geoip::visitor_country()
|
||||||
)
|
)
|
||||||
), new FieldSet(
|
), new FieldList(
|
||||||
// List the action buttons here
|
// List the action buttons here
|
||||||
new FormAction("signup", "Sign up")
|
new FormAction("signup", "Sign up")
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ Readonly on a Form
|
|||||||
$myForm->makeReadonly();
|
$myForm->makeReadonly();
|
||||||
|
|
||||||
|
|
||||||
Readonly on a FieldSet
|
Readonly on a FieldList
|
||||||
|
|
||||||
:::php
|
:::php
|
||||||
$myFieldSet->makeReadonly();
|
$myFieldSet->makeReadonly();
|
||||||
@ -170,12 +170,12 @@ First of all, you need to create your form on it's own class, that way you can d
|
|||||||
class MyForm extends Form {
|
class MyForm extends Form {
|
||||||
|
|
||||||
function __construct($controller, $name) {
|
function __construct($controller, $name) {
|
||||||
$fields = new FieldSet(
|
$fields = new FieldList(
|
||||||
new TextField('FirstName', 'First name'),
|
new TextField('FirstName', 'First name'),
|
||||||
new EmailField('Email', 'Email address')
|
new EmailField('Email', 'Email address')
|
||||||
);
|
);
|
||||||
|
|
||||||
$actions = new FieldSet(
|
$actions = new FieldList(
|
||||||
new FormAction('submit', 'Submit')
|
new FormAction('submit', 'Submit')
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -280,5 +280,5 @@ Adds a new text field called FavouriteColour next to the Content field in the CM
|
|||||||
|
|
||||||
* `[api:Form]`
|
* `[api:Form]`
|
||||||
* `[api:FormField]`
|
* `[api:FormField]`
|
||||||
* `[api:FieldSet]`
|
* `[api:FieldList]`
|
||||||
* `[api:FormAction]`
|
* `[api:FormAction]`
|
@ -78,7 +78,7 @@ See [form](/topics/forms) and [tutorial:2-extending-a-basic-site](/tutorials/2-e
|
|||||||
|
|
||||||
### removeFieldFromTab()
|
### removeFieldFromTab()
|
||||||
|
|
||||||
Overloading `getCMSFields()` you can call `removeFieldFromTab()` on a `[api:FieldSet]` object. For example, if you don't
|
Overloading `getCMSFields()` you can call `removeFieldFromTab()` on a `[api:FieldList]` object. For example, if you don't
|
||||||
want the MenuTitle field to show on your page, which is inherited from `[api:SiteTree]`.
|
want the MenuTitle field to show on your page, which is inherited from `[api:SiteTree]`.
|
||||||
|
|
||||||
:::php
|
:::php
|
||||||
@ -105,7 +105,7 @@ required on a certain page-type.
|
|||||||
class MyForm extends Form {
|
class MyForm extends Form {
|
||||||
|
|
||||||
function __construct($controller, $name) {
|
function __construct($controller, $name) {
|
||||||
// add a default FieldSet of form fields
|
// add a default FieldList of form fields
|
||||||
$member = singleton('Member');
|
$member = singleton('Member');
|
||||||
|
|
||||||
$fields = $member->formFields();
|
$fields = $member->formFields();
|
||||||
@ -113,7 +113,7 @@ required on a certain page-type.
|
|||||||
// We don't want the Country field from our default set of fields, so we remove it.
|
// We don't want the Country field from our default set of fields, so we remove it.
|
||||||
$fields->removeByName('Country');
|
$fields->removeByName('Country');
|
||||||
|
|
||||||
$actions = new FieldSet(
|
$actions = new FieldList(
|
||||||
new FormAction('submit', 'Submit')
|
new FormAction('submit', 'Submit')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ Photos), and $description, a short description that will appear in the cms edito
|
|||||||
Flickr). The class may also specify functions to be used in the template like a page type can.
|
Flickr). The class may also specify functions to be used in the template like a page type can.
|
||||||
|
|
||||||
If a Widget has configurable options, then it can specify a number of database fields to store these options in via the
|
If a Widget has configurable options, then it can specify a number of database fields to store these options in via the
|
||||||
static $db array, and also specify a getCMSFields function that returns a !FieldSet, much the same way as a page type
|
static $db array, and also specify a getCMSFields function that returns a !FieldList, much the same way as a page type
|
||||||
does.
|
does.
|
||||||
|
|
||||||
An example widget is below:
|
An example widget is below:
|
||||||
@ -139,7 +139,7 @@ An example widget is below:
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getCMSFields() {
|
function getCMSFields() {
|
||||||
return new FieldSet(
|
return new FieldList(
|
||||||
new TextField("User", "User"),
|
new TextField("User", "User"),
|
||||||
new TextField("PhotoSet", "Photo Set"),
|
new TextField("PhotoSet", "Photo Set"),
|
||||||
new TextField("Tags", "Tags"),
|
new TextField("Tags", "Tags"),
|
||||||
@ -246,10 +246,10 @@ sure that your controller follows the usual naming conventions, and it will be a
|
|||||||
return new Form(
|
return new Form(
|
||||||
$this,
|
$this,
|
||||||
'MyFormName',
|
'MyFormName',
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new TextField('TestValue')
|
new TextField('TestValue')
|
||||||
),
|
),
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new FormAction('doAction')
|
new FormAction('doAction')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -192,7 +192,7 @@ Let's walk through this method.
|
|||||||
|
|
||||||
|
|
||||||
Firstly, we get the fields from the parent class; we want to add fields, not replace them. The *$fields* variable
|
Firstly, we get the fields from the parent class; we want to add fields, not replace them. The *$fields* variable
|
||||||
returned is a `[api:FieldSet]` object.
|
returned is a `[api:FieldList]` object.
|
||||||
|
|
||||||
:::php
|
:::php
|
||||||
$fields->addFieldToTab('Root.Content', new DateField('Date'), 'Content');
|
$fields->addFieldToTab('Root.Content', new DateField('Date'), 'Content');
|
||||||
|
@ -33,7 +33,7 @@ the form in a method on *HomePage_Controller*.
|
|||||||
|
|
||||||
function BrowserPollForm() {
|
function BrowserPollForm() {
|
||||||
// Create fields
|
// Create fields
|
||||||
$fields = new FieldSet(
|
$fields = new FieldList(
|
||||||
new TextField('Name'),
|
new TextField('Name'),
|
||||||
new OptionsetField('Browser', 'Your Favourite Browser', array(
|
new OptionsetField('Browser', 'Your Favourite Browser', array(
|
||||||
'Firefox' => 'Firefox',
|
'Firefox' => 'Firefox',
|
||||||
@ -46,7 +46,7 @@ the form in a method on *HomePage_Controller*.
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Create actions
|
// Create actions
|
||||||
$actions = new FieldSet(
|
$actions = new FieldList(
|
||||||
new FormAction('doBrowserPoll', 'Submit')
|
new FormAction('doBrowserPoll', 'Submit')
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ Let's step through this code.
|
|||||||
|
|
||||||
:::php
|
:::php
|
||||||
// Create fields
|
// Create fields
|
||||||
$fields = new FieldSet(
|
$fields = new FieldList(
|
||||||
new TextField('Name'),
|
new TextField('Name'),
|
||||||
new OptionsetField('Browser', 'Your Favourite Browser', array(
|
new OptionsetField('Browser', 'Your Favourite Browser', array(
|
||||||
'Firefox' => 'Firefox',
|
'Firefox' => 'Firefox',
|
||||||
@ -78,7 +78,7 @@ Let's step through this code.
|
|||||||
|
|
||||||
First we create our form fields.
|
First we create our form fields.
|
||||||
|
|
||||||
We do this by creating a `[api:FieldSet]` and passing our fields as arguments. The first field is a new
|
We do this by creating a `[api:FieldList]` and passing our fields as arguments. The first field is a new
|
||||||
`[api:TextField]` with the name 'Name'.
|
`[api:TextField]` with the name 'Name'.
|
||||||
|
|
||||||
There is a second argument when creating a field which specifies the text on the label of the field. If no second
|
There is a second argument when creating a field which specifies the text on the label of the field. If no second
|
||||||
@ -88,7 +88,7 @@ The second field we create is an `[api:OptionsetField]`. This is a dropdown, and
|
|||||||
array mapping the values to the options listed in the dropdown.
|
array mapping the values to the options listed in the dropdown.
|
||||||
|
|
||||||
:::php
|
:::php
|
||||||
$actions = new FieldSet(
|
$actions = new FieldList(
|
||||||
new FormAction('doBrowserPoll', 'Submit');
|
new FormAction('doBrowserPoll', 'Submit');
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ button.
|
|||||||
|
|
||||||
Here we create a 'Submit' button which calls the 'doBrowserPoll' method, which we will create later.
|
Here we create a 'Submit' button which calls the 'doBrowserPoll' method, which we will create later.
|
||||||
|
|
||||||
All the form actions (in this case only one) are collected into a `[api:FieldSet]` object the same way we did with
|
All the form actions (in this case only one) are collected into a `[api:FieldList]` object the same way we did with
|
||||||
the fields.
|
the fields.
|
||||||
|
|
||||||
:::php
|
:::php
|
||||||
@ -111,7 +111,7 @@ Finally we create the `[api:Form]` object and return it.
|
|||||||
|
|
||||||
The first argument is the controller that contains the form, in most cases '$this'. The second is the name of the method
|
The first argument is the controller that contains the form, in most cases '$this'. The second is the name of the method
|
||||||
that returns the form, which is 'BrowserPollForm' in our case. The third and fourth arguments are the
|
that returns the form, which is 'BrowserPollForm' in our case. The third and fourth arguments are the
|
||||||
FieldSets containing the fields and form actions respectively.
|
FieldLists containing the fields and form actions respectively.
|
||||||
|
|
||||||
After creating the form function, we need to add the form to our home page template.
|
After creating the form function, we need to add the form to our home page template.
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ Add the following code to the form style sheet:
|
|||||||
margin: 20px 10px 0 0;
|
margin: 20px 10px 0 0;
|
||||||
width: 20%;
|
width: 20%;
|
||||||
}
|
}
|
||||||
form fieldset {
|
form FieldList {
|
||||||
border:0;
|
border:0;
|
||||||
}
|
}
|
||||||
#BrowserPoll .message {
|
#BrowserPoll .message {
|
||||||
|
@ -54,11 +54,11 @@ search on your site is to create a form for the user to type their query. Create
|
|||||||
function SearchForm() {
|
function SearchForm() {
|
||||||
$searchText = isset($this->Query) ? $this->Query : 'Search';
|
$searchText = isset($this->Query) ? $this->Query : 'Search';
|
||||||
|
|
||||||
$fields = new FieldSet(
|
$fields = new FieldList(
|
||||||
new TextField("Search", "", $searchText)
|
new TextField("Search", "", $searchText)
|
||||||
);
|
);
|
||||||
|
|
||||||
$actions = new FieldSet(
|
$actions = new FieldList(
|
||||||
new FormAction('results', 'Go')
|
new FormAction('results', 'Go')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ The first step is to create the student and project objects.
|
|||||||
);
|
);
|
||||||
|
|
||||||
function getCMSFields_forPopup() {
|
function getCMSFields_forPopup() {
|
||||||
$fields = new FieldSet();
|
$fields = new FieldList();
|
||||||
|
|
||||||
$fields->push( new TextField( 'FirstName', 'First Name' ) );
|
$fields->push( new TextField( 'FirstName', 'First Name' ) );
|
||||||
$fields->push( new TextField( 'Lastname' ) );
|
$fields->push( new TextField( 'Lastname' ) );
|
||||||
@ -153,7 +153,7 @@ Let’s walk through the parameters of the *HasOneComplexTableField* constructor
|
|||||||
You can also directly replace the last parameter by this code :
|
You can also directly replace the last parameter by this code :
|
||||||
|
|
||||||
:::php
|
:::php
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new TextField( 'FirstName', 'First Name' ),
|
new TextField( 'FirstName', 'First Name' ),
|
||||||
new TextField( 'Lastname' ),
|
new TextField( 'Lastname' ),
|
||||||
new TextField( 'Nationality' )
|
new TextField( 'Nationality' )
|
||||||
@ -381,7 +381,7 @@ The first step is to create the module object and set the relation with the *Pro
|
|||||||
);
|
);
|
||||||
|
|
||||||
function getCMSFields_forPopup() {
|
function getCMSFields_forPopup() {
|
||||||
$fields = new FieldSet();
|
$fields = new FieldList();
|
||||||
$fields->push( new TextField( 'Name' ) );
|
$fields->push( new TextField( 'Name' ) );
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
@ -775,7 +775,7 @@ class File extends DataObject {
|
|||||||
*
|
*
|
||||||
* Needs to be enabled through {@link AssetAdmin::$metadata_upload_enabled}
|
* Needs to be enabled through {@link AssetAdmin::$metadata_upload_enabled}
|
||||||
*
|
*
|
||||||
* @return FieldSet
|
* @return FieldList
|
||||||
*/
|
*/
|
||||||
function uploadMetadataFields() {
|
function uploadMetadataFields() {
|
||||||
$fields = new FieldList();
|
$fields = new FieldList();
|
||||||
|
@ -379,8 +379,8 @@ class Folder extends File {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the FieldSet used to edit this folder in the CMS.
|
* Return the FieldList 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 FieldList by subclassing folder, or by creating a {@link DataExtension}
|
||||||
* and implemeting updateCMSFields(FieldList $fields) on that extension.
|
* and implemeting updateCMSFields(FieldList $fields) on that extension.
|
||||||
*/
|
*/
|
||||||
function getCMSFields() {
|
function getCMSFields() {
|
||||||
|
@ -32,7 +32,7 @@ class ComplexTableField extends TableListField {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines the fields of the detail pop-up form. It can take many forms:
|
* Determines the fields of the detail pop-up form. It can take many forms:
|
||||||
* - A FieldSet object: Use that field set directly.
|
* - A FieldList object: Use that field set directly.
|
||||||
* - A method name, eg, 'getCMSFields': Call that method on the child object to get the fields.
|
* - A method name, eg, 'getCMSFields': Call that method on the child object to get the fields.
|
||||||
*/
|
*/
|
||||||
protected $addTitle;
|
protected $addTitle;
|
||||||
@ -330,7 +330,7 @@ JS;
|
|||||||
/**
|
/**
|
||||||
* @return FieldList
|
* @return FieldList
|
||||||
*/
|
*/
|
||||||
function createFieldSet() {
|
function createFieldList() {
|
||||||
$fieldset = new FieldList();
|
$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));
|
||||||
@ -352,7 +352,7 @@ JS;
|
|||||||
* Return the object-specific fields for the given record, to be shown in the detail pop-up
|
* Return the object-specific fields for the given record, to be shown in the detail pop-up
|
||||||
*
|
*
|
||||||
* This won't include all the CTF-specific 'plumbing; this method is called by self::getFieldsFor()
|
* This won't include all the CTF-specific 'plumbing; this method is called by self::getFieldsFor()
|
||||||
* and the result is then processed further to get the actual FieldSet for the form.
|
* and the result is then processed further to get the actual FieldList for the form.
|
||||||
*
|
*
|
||||||
* The default implementation of this processes the value of $this->detailFormFields; consequently, if you want to
|
* The default implementation of this processes the value of $this->detailFormFields; consequently, if you want to
|
||||||
* set the value of the fields to something that $this->detailFormFields doesn't allow, you can do so by overloading
|
* set the value of the fields to something that $this->detailFormFields doesn't allow, you can do so by overloading
|
||||||
|
@ -52,7 +52,7 @@ class FieldGroup extends CompositeField {
|
|||||||
if(is_array($arg1) || is_a($arg1, 'FieldSet')) {
|
if(is_array($arg1) || is_a($arg1, 'FieldSet')) {
|
||||||
$fields = $arg1;
|
$fields = $arg1;
|
||||||
|
|
||||||
} else if(is_array($arg2) || is_a($arg2, 'FieldSet')) {
|
} else if(is_array($arg2) || is_a($arg2, 'FieldList')) {
|
||||||
$this->title = $arg1;
|
$this->title = $arg1;
|
||||||
$fields = $arg2;
|
$fields = $arg2;
|
||||||
|
|
||||||
|
40
forms/FieldList.php
Executable file → Normal file
40
forms/FieldList.php
Executable file → Normal file
@ -80,7 +80,7 @@ class FieldList extends ArrayList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an extra field to a tab within this fieldset.
|
* Add an extra field to a tab within this FieldList.
|
||||||
* This is most commonly used when overloading getCMSFields()
|
* This is most commonly used when overloading getCMSFields()
|
||||||
*
|
*
|
||||||
* @param string $tabName The name of the tab or tabset. Subtabs can be referred to as TabSet.Tab or TabSet.Tab.Subtab.
|
* @param string $tabName The name of the tab or tabset. Subtabs can be referred to as TabSet.Tab or TabSet.Tab.Subtab.
|
||||||
@ -101,7 +101,7 @@ class FieldList extends ArrayList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a number of extra fields to a tab within this fieldset.
|
* Add a number of extra fields to a tab within this FieldList.
|
||||||
* This is most commonly used when overloading getCMSFields()
|
* This is most commonly used when overloading getCMSFields()
|
||||||
*
|
*
|
||||||
* @param string $tabName The name of the tab or tabset. Subtabs can be referred to as TabSet.Tab or TabSet.Tab.Subtab.
|
* @param string $tabName The name of the tab or tabset. Subtabs can be referred to as TabSet.Tab or TabSet.Tab.Subtab.
|
||||||
@ -143,7 +143,7 @@ class FieldList extends ArrayList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a number of fields from a Tab/TabSet within this FieldSet.
|
* Removes a number of fields from a Tab/TabSet within this FieldList.
|
||||||
*
|
*
|
||||||
* @param string $tabName The name of the Tab or TabSet field
|
* @param string $tabName The name of the Tab or TabSet field
|
||||||
* @param array $fields A list of fields, e.g. array('Name', 'Email')
|
* @param array $fields A list of fields, e.g. array('Name', 'Email')
|
||||||
@ -159,7 +159,7 @@ class FieldList extends ArrayList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a field from this FieldSet by Name.
|
* Remove a field from this FieldList by Name.
|
||||||
* The field could also be inside a CompositeField.
|
* The field could also be inside a CompositeField.
|
||||||
*
|
*
|
||||||
* @param string $fieldName The name of the field or tab
|
* @param string $fieldName The name of the field or tab
|
||||||
@ -169,7 +169,7 @@ class FieldList extends ArrayList {
|
|||||||
*/
|
*/
|
||||||
public function removeByName($fieldName, $dataFieldOnly = false) {
|
public function removeByName($fieldName, $dataFieldOnly = false) {
|
||||||
if(!$fieldName) {
|
if(!$fieldName) {
|
||||||
user_error('FieldSet::removeByName() was called with a blank field name.', E_USER_WARNING);
|
user_error('FieldList::removeByName() was called with a blank field name.', E_USER_WARNING);
|
||||||
}
|
}
|
||||||
$this->flushFieldsCache();
|
$this->flushFieldsCache();
|
||||||
|
|
||||||
@ -257,7 +257,7 @@ class FieldList extends ArrayList {
|
|||||||
public function findOrMakeTab($tabName, $title = null) {
|
public function findOrMakeTab($tabName, $title = null) {
|
||||||
$parts = explode('.',$tabName);
|
$parts = explode('.',$tabName);
|
||||||
|
|
||||||
// We could have made this recursive, but I've chosen to keep all the logic code within FieldSet rather than add it to TabSet and Tab too.
|
// We could have made this recursive, but I've chosen to keep all the logic code within FieldList rather than add it to TabSet and Tab too.
|
||||||
$currentPointer = $this;
|
$currentPointer = $this;
|
||||||
foreach($parts as $k => $part) {
|
foreach($parts as $k => $part) {
|
||||||
$parentPointer = $currentPointer;
|
$parentPointer = $currentPointer;
|
||||||
@ -274,7 +274,7 @@ class FieldList extends ArrayList {
|
|||||||
$parentPointer->push($currentPointer);
|
$parentPointer->push($currentPointer);
|
||||||
} else {
|
} else {
|
||||||
$withName = ($parentPointer->hasMethod('Name')) ? " named '{$parentPointer->Name()}'" : null;
|
$withName = ($parentPointer->hasMethod('Name')) ? " named '{$parentPointer->Name()}'" : null;
|
||||||
user_error("FieldSet::addFieldToTab() Tried to add a tab to object '{$parentPointer->class}'{$withName} - '$part' didn't exist.", E_USER_ERROR);
|
user_error("FieldList::addFieldToTab() Tried to add a tab to object '{$parentPointer->class}'{$withName} - '$part' didn't exist.", E_USER_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -324,7 +324,7 @@ class FieldList extends ArrayList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts a field before a particular field in a FieldSet.
|
* Inserts a field before a particular field in a FieldList.
|
||||||
*
|
*
|
||||||
* @param FormField $item The form field to insert
|
* @param FormField $item The form field to insert
|
||||||
* @param string $name Name of the field to insert before
|
* @param string $name Name of the field to insert before
|
||||||
@ -349,7 +349,7 @@ class FieldList extends ArrayList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts a field after a particular field in a FieldSet.
|
* Inserts a field after a particular field in a FieldList.
|
||||||
*
|
*
|
||||||
* @param FormField $item The form field to insert
|
* @param FormField $item The form field to insert
|
||||||
* @param string $name Name of the field to insert after
|
* @param string $name Name of the field to insert after
|
||||||
@ -374,7 +374,7 @@ class FieldList extends ArrayList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Push a single field into this FieldSet instance.
|
* Push a single field into this FieldList instance.
|
||||||
*
|
*
|
||||||
* @param FormField $item The FormField to add
|
* @param FormField $item The FormField to add
|
||||||
* @param string $key An option array key (field name)
|
* @param string $key An option array key (field name)
|
||||||
@ -386,7 +386,7 @@ class FieldList extends ArrayList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler method called before the FieldSet is going to be manipulated.
|
* Handler method called before the FieldList is going to be manipulated.
|
||||||
*/
|
*/
|
||||||
protected function onBeforeInsert($item) {
|
protected function onBeforeInsert($item) {
|
||||||
$this->flushFieldsCache();
|
$this->flushFieldsCache();
|
||||||
@ -395,9 +395,9 @@ class FieldList extends ArrayList {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the Form instance for this FieldSet.
|
* Set the Form instance for this FieldList.
|
||||||
*
|
*
|
||||||
* @param Form $form The form to set this FieldSet to
|
* @param Form $form The form to set this FieldList to
|
||||||
*/
|
*/
|
||||||
public function setForm($form) {
|
public function setForm($form) {
|
||||||
foreach($this as $field) $field->setForm($form);
|
foreach($this as $field) $field->setForm($form);
|
||||||
@ -406,7 +406,7 @@ class FieldList extends ArrayList {
|
|||||||
/**
|
/**
|
||||||
* Load the given data into this form.
|
* Load the given data into this form.
|
||||||
*
|
*
|
||||||
* @param data An map of data to load into the FieldSet
|
* @param data An map of data to load into the FieldList
|
||||||
*/
|
*/
|
||||||
public function setValues($data) {
|
public function setValues($data) {
|
||||||
foreach($this->dataFields() as $field) {
|
foreach($this->dataFields() as $field) {
|
||||||
@ -420,7 +420,7 @@ class FieldList extends ArrayList {
|
|||||||
* in a form - including fields nested in {@link CompositeFields}.
|
* in a form - including fields nested in {@link CompositeFields}.
|
||||||
* Useful when doing custom field layouts.
|
* Useful when doing custom field layouts.
|
||||||
*
|
*
|
||||||
* @return FieldSet
|
* @return FieldList
|
||||||
*/
|
*/
|
||||||
function HiddenFields() {
|
function HiddenFields() {
|
||||||
$hiddenFields = new HiddenFieldSet();
|
$hiddenFields = new HiddenFieldSet();
|
||||||
@ -434,10 +434,10 @@ class FieldList extends ArrayList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform this FieldSet with a given tranform method,
|
* Transform this FieldList with a given tranform method,
|
||||||
* e.g. $this->transform(new ReadonlyTransformation())
|
* e.g. $this->transform(new ReadonlyTransformation())
|
||||||
*
|
*
|
||||||
* @return FieldSet
|
* @return FieldList
|
||||||
*/
|
*/
|
||||||
function transform($trans) {
|
function transform($trans) {
|
||||||
$this->flushFieldsCache();
|
$this->flushFieldsCache();
|
||||||
@ -461,9 +461,9 @@ class FieldList extends ArrayList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transforms this FieldSet instance to readonly.
|
* Transforms this FieldList instance to readonly.
|
||||||
*
|
*
|
||||||
* @return FieldSet
|
* @return FieldList
|
||||||
*/
|
*/
|
||||||
function makeReadonly() {
|
function makeReadonly() {
|
||||||
return $this->transform(new ReadonlyTransformation());
|
return $this->transform(new ReadonlyTransformation());
|
||||||
@ -481,7 +481,7 @@ class FieldList extends ArrayList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change the order of fields in this FieldSet by specifying an ordered list of field names.
|
* Change the order of fields in this FieldList by specifying an ordered list of field names.
|
||||||
* This works well in conjunction with SilverStripe's scaffolding functions: take the scaffold, and
|
* This works well in conjunction with SilverStripe's scaffolding functions: take the scaffold, and
|
||||||
* shuffle the fields around to the order that you want.
|
* shuffle the fields around to the order that you want.
|
||||||
*
|
*
|
||||||
|
@ -142,8 +142,8 @@ 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 FieldList $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 FieldList} of {@link FormField} objects.
|
||||||
* @param FieldList $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 FieldLis} 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, FieldList $fields, FieldList $actions, $validator = null) {
|
function __construct($controller, $name, FieldList $fields, FieldList $actions, $validator = null) {
|
||||||
@ -338,7 +338,7 @@ class Form extends RequestHandler {
|
|||||||
/**
|
/**
|
||||||
* Handle a field request.
|
* Handle a field request.
|
||||||
* Uses {@link Form->dataFieldByName()} to find a matching field,
|
* Uses {@link Form->dataFieldByName()} to find a matching field,
|
||||||
* and falls back to {@link FieldSet->fieldByName()} to look
|
* and falls back to {@link FieldList->fieldByName()} to look
|
||||||
* for tabs instead. This means that if you have a tab and a
|
* for tabs instead. This means that if you have a tab and a
|
||||||
* formfield with the same name, this method gives priority
|
* formfield with the same name, this method gives priority
|
||||||
* to the formfield.
|
* to the formfield.
|
||||||
@ -460,7 +460,7 @@ class Form extends RequestHandler {
|
|||||||
/**
|
/**
|
||||||
* Generate extra special fields - namely the security token field (if required).
|
* Generate extra special fields - namely the security token field (if required).
|
||||||
*
|
*
|
||||||
* @return FieldSet
|
* @return FieldList
|
||||||
*/
|
*/
|
||||||
public function getExtraFields() {
|
public function getExtraFields() {
|
||||||
$extraFields = new FieldList();
|
$extraFields = new FieldList();
|
||||||
@ -483,7 +483,7 @@ class Form extends RequestHandler {
|
|||||||
/**
|
/**
|
||||||
* Return the form's fields - used by the templates
|
* Return the form's fields - used by the templates
|
||||||
*
|
*
|
||||||
* @return FieldSet The form fields
|
* @return FieldList The form fields
|
||||||
*/
|
*/
|
||||||
function Fields() {
|
function Fields() {
|
||||||
foreach($this->getExtraFields() as $field) {
|
foreach($this->getExtraFields() as $field) {
|
||||||
@ -498,7 +498,7 @@ class Form extends RequestHandler {
|
|||||||
* in a form - including fields nested in {@link CompositeFields}.
|
* in a form - including fields nested in {@link CompositeFields}.
|
||||||
* Useful when doing custom field layouts.
|
* Useful when doing custom field layouts.
|
||||||
*
|
*
|
||||||
* @return FieldSet
|
* @return FieldList
|
||||||
*/
|
*/
|
||||||
function HiddenFields() {
|
function HiddenFields() {
|
||||||
return $this->fields->HiddenFields();
|
return $this->fields->HiddenFields();
|
||||||
@ -531,7 +531,7 @@ class Form extends RequestHandler {
|
|||||||
/**
|
/**
|
||||||
* Return the form's action buttons - used by the templates
|
* Return the form's action buttons - used by the templates
|
||||||
*
|
*
|
||||||
* @return FieldSet The action list
|
* @return FieldList The action list
|
||||||
*/
|
*/
|
||||||
function Actions() {
|
function Actions() {
|
||||||
return $this->actions;
|
return $this->actions;
|
||||||
@ -916,7 +916,7 @@ class Form extends RequestHandler {
|
|||||||
* It will call $object->MyField to get the value of MyField.
|
* It will call $object->MyField to get the value of MyField.
|
||||||
* If you passed an array, it will call $object[MyField].
|
* If you passed an array, it will call $object[MyField].
|
||||||
* Doesn't save into dataless FormFields ({@link DatalessField}),
|
* Doesn't save into dataless FormFields ({@link DatalessField}),
|
||||||
* as determined by {@link FieldSet->dataFields()}.
|
* as determined by {@link FieldList->dataFields()}.
|
||||||
*
|
*
|
||||||
* By default, if a field isn't set (as determined by isset()),
|
* By default, if a field isn't set (as determined by isset()),
|
||||||
* its value will not be saved to the field, retaining
|
* its value will not be saved to the field, retaining
|
||||||
@ -925,7 +925,7 @@ class Form extends RequestHandler {
|
|||||||
* Passed data should not be escaped, and is saved to the FormField instances unescaped.
|
* Passed data should not be escaped, and is saved to the FormField instances unescaped.
|
||||||
* Escaping happens automatically on saving the data through {@link saveInto()}.
|
* Escaping happens automatically on saving the data through {@link saveInto()}.
|
||||||
*
|
*
|
||||||
* @uses FieldSet->dataFields()
|
* @uses FieldList->dataFields()
|
||||||
* @uses FormField->setValue()
|
* @uses FormField->setValue()
|
||||||
*
|
*
|
||||||
* @param array|DataObject $data
|
* @param array|DataObject $data
|
||||||
@ -1022,7 +1022,7 @@ class Form extends RequestHandler {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the submitted data from this form through
|
* Get the submitted data from this form through
|
||||||
* {@link FieldSet->dataFields()}, which filters out
|
* {@link FieldList->dataFields()}, which filters out
|
||||||
* any form-specific data like form-actions.
|
* any form-specific data like form-actions.
|
||||||
* Calls {@link FormField->dataValue()} on each field,
|
* Calls {@link FormField->dataValue()} on each field,
|
||||||
* which returns a value suitable for insertion into a DataObject
|
* which returns a value suitable for insertion into a DataObject
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* Represents a field in a form.
|
* Represents a field in a form.
|
||||||
*
|
*
|
||||||
* A FieldSet contains a number of FormField objects which make up the whole of a form.
|
* A FieldList contains a number of FormField objects which make up the whole of a form.
|
||||||
* In addition to single fields, FormField objects can be "composite", for example, the {@link TabSet}
|
* In addition to single fields, FormField objects can be "composite", for example, the {@link TabSet}
|
||||||
* field. Composite fields let us define complex forms without having to resort to custom HTML.
|
* field. Composite fields let us define complex forms without having to resort to custom HTML.
|
||||||
*
|
*
|
||||||
@ -53,8 +53,8 @@ class FormField extends RequestHandler {
|
|||||||
protected $tabIndex;
|
protected $tabIndex;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores a reference to the FieldSet that contains this object.
|
* Stores a reference to the FieldList that contains this object.
|
||||||
* @var FieldSet
|
* @var FieldList
|
||||||
*/
|
*/
|
||||||
protected $containerFieldSet;
|
protected $containerFieldSet;
|
||||||
|
|
||||||
@ -480,7 +480,7 @@ HTML;
|
|||||||
* make sense for data-focused methods to look at them. By overloading hasData() to return false,
|
* make sense for data-focused methods to look at them. By overloading hasData() to return false,
|
||||||
* you can prevent any data-focused methods from looking at it.
|
* you can prevent any data-focused methods from looking at it.
|
||||||
*
|
*
|
||||||
* @see FieldSet::collateDataFields()
|
* @see FieldList::collateDataFields()
|
||||||
*/
|
*/
|
||||||
function hasData() { return true; }
|
function hasData() { return true; }
|
||||||
|
|
||||||
@ -654,7 +654,7 @@ HTML;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the fieldset that contains this field.
|
* Set the FieldList that contains this field.
|
||||||
*
|
*
|
||||||
* @param FieldList $containerFieldSet
|
* @param FieldList $containerFieldSet
|
||||||
*/
|
*/
|
||||||
|
@ -62,7 +62,7 @@ class FormScaffolder extends Object {
|
|||||||
* Depending on those parameters, the fields can be used in ajax-context,
|
* Depending on those parameters, the fields can be used in ajax-context,
|
||||||
* contain {@link TabSet}s etc.
|
* contain {@link TabSet}s etc.
|
||||||
*
|
*
|
||||||
* @return FieldSet
|
* @return FieldList
|
||||||
*/
|
*/
|
||||||
public function getFieldSet() {
|
public function getFieldSet() {
|
||||||
$fields = new FieldList();
|
$fields = new FieldList();
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
* $map = $myDoSet->toDropDownMap();
|
* $map = $myDoSet->toDropDownMap();
|
||||||
*
|
*
|
||||||
* // Instantiate the OptionsetField
|
* // Instantiate the OptionsetField
|
||||||
* $fieldset = new FieldList(
|
* $FieldList = new FieldList(
|
||||||
* new OptionsetField(
|
* new OptionsetField(
|
||||||
* $name = "Foobar",
|
* $name = "Foobar",
|
||||||
* $title = "FooBar's optionset",
|
* $title = "FooBar's optionset",
|
||||||
|
@ -133,7 +133,7 @@ class TabSet extends CompositeField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts a field before a particular field in a FieldSet.
|
* Inserts a field before a particular field in a FieldList.
|
||||||
*
|
*
|
||||||
* @param FormField $item The form field to insert
|
* @param FormField $item The form field to insert
|
||||||
* @param string $name Name of the field to insert before
|
* @param string $name Name of the field to insert before
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
* @param $sourceSort string
|
* @param $sourceSort string
|
||||||
* @param $sourceJoin string
|
* @param $sourceJoin string
|
||||||
*
|
*
|
||||||
* @todo We should refactor this to support a single FieldSet instead of evaluated Strings for building FormFields
|
* @todo We should refactor this to support a single FieldList instead of evaluated Strings for building FormFields
|
||||||
*
|
*
|
||||||
* @package forms
|
* @package forms
|
||||||
* @subpackage fields-relational
|
* @subpackage fields-relational
|
||||||
@ -43,7 +43,7 @@ class TableField extends TableListField {
|
|||||||
protected $filterValue = null;
|
protected $filterValue = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var $fieldTypes FieldSet
|
* @var $fieldTypes FieldList
|
||||||
* Caution: Use {@setExtraData()} instead of manually adding HiddenFields if you want to
|
* Caution: Use {@setExtraData()} instead of manually adding HiddenFields if you want to
|
||||||
* preset relations or other default data.
|
* preset relations or other default data.
|
||||||
*/
|
*/
|
||||||
@ -206,7 +206,7 @@ class TableField extends TableListField {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a new {@link TableField} instance
|
* Generates a new {@link TableField} instance
|
||||||
* by loading a fieldset for this row into a temporary form.
|
* by loading a FieldList for this row into a temporary form.
|
||||||
*
|
*
|
||||||
* @param DataObject $dataObj
|
* @param DataObject $dataObj
|
||||||
* @return TableField_Item
|
* @return TableField_Item
|
||||||
|
@ -172,7 +172,7 @@ abstract class DataExtension extends Extension {
|
|||||||
*
|
*
|
||||||
* Caution: Use {@link FieldList->addFieldToTab()} to add fields.
|
* Caution: Use {@link FieldList->addFieldToTab()} to add fields.
|
||||||
*
|
*
|
||||||
* @param FieldList $fields FieldSet with a contained TabSet
|
* @param FieldList $fields FieldList with a contained TabSet
|
||||||
*/
|
*/
|
||||||
function updateCMSFields(FieldList $fields) {
|
function updateCMSFields(FieldList $fields) {
|
||||||
}
|
}
|
||||||
@ -181,9 +181,9 @@ abstract class DataExtension extends Extension {
|
|||||||
* This function is used to provide modifications to the form used
|
* This function is used to provide modifications to the form used
|
||||||
* for front end forms. {@link DataObject->getFrontEndFields()}
|
* for front end forms. {@link DataObject->getFrontEndFields()}
|
||||||
*
|
*
|
||||||
* Caution: Use {@link FieldSet->push()} to add fields.
|
* Caution: Use {@link FieldList->push()} to add fields.
|
||||||
*
|
*
|
||||||
* @param FieldList $fields FieldSet without TabSet nesting
|
* @param FieldList $fields FieldList without TabSet nesting
|
||||||
*/
|
*/
|
||||||
function updateFrontEndFields(FieldList $fields) {
|
function updateFrontEndFields(FieldList $fields) {
|
||||||
}
|
}
|
||||||
@ -192,7 +192,7 @@ abstract class DataExtension extends Extension {
|
|||||||
* 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 FieldList $actions FieldSet
|
* @param FieldList $actions FieldList
|
||||||
*/
|
*/
|
||||||
function updateCMSActions(FieldList $actions) {
|
function updateCMSActions(FieldList $actions) {
|
||||||
}
|
}
|
||||||
|
@ -1764,7 +1764,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
* @param array $_params
|
* @param array $_params
|
||||||
* 'fieldClasses': Associative array of field names as keys and FormField classes as values
|
* 'fieldClasses': Associative array of field names as keys and FormField classes as values
|
||||||
* 'restrictFields': Numeric array of a field name whitelist
|
* 'restrictFields': Numeric array of a field name whitelist
|
||||||
* @return FieldSet
|
* @return FieldList
|
||||||
*/
|
*/
|
||||||
public function scaffoldSearchFields($_params = null) {
|
public function scaffoldSearchFields($_params = null) {
|
||||||
$params = array_merge(
|
$params = array_merge(
|
||||||
@ -1821,7 +1821,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
* @uses FormScaffolder
|
* @uses FormScaffolder
|
||||||
*
|
*
|
||||||
* @param array $_params Associative array passing through properties to {@link FormScaffolder}.
|
* @param array $_params Associative array passing through properties to {@link FormScaffolder}.
|
||||||
* @return FieldSet
|
* @return FieldList
|
||||||
*/
|
*/
|
||||||
public function scaffoldFormFields($_params = null) {
|
public function scaffoldFormFields($_params = null) {
|
||||||
$params = array_merge(
|
$params = array_merge(
|
||||||
@ -1867,7 +1867,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
* @see Good example of complex FormField building: SiteTree::getCMSFields()
|
* @see Good example of complex FormField building: SiteTree::getCMSFields()
|
||||||
*
|
*
|
||||||
* @param array $params See {@link scaffoldFormFields()}
|
* @param array $params See {@link scaffoldFormFields()}
|
||||||
* @return FieldSet Returns a TabSet for usage within the CMS - don't use for frontend forms.
|
* @return FieldList Returns a TabSet for usage within the CMS - don't use for frontend forms.
|
||||||
*/
|
*/
|
||||||
public function getCMSFields($params = null) {
|
public function getCMSFields($params = null) {
|
||||||
$tabbedFields = $this->scaffoldFormFields(array_merge(
|
$tabbedFields = $this->scaffoldFormFields(array_merge(
|
||||||
@ -1888,7 +1888,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
* need to be overload by solid dataobject, so that the customised actions of that dataobject,
|
* need to be overload by solid dataobject, so that the customised actions of that dataobject,
|
||||||
* including that dataobject's extensions customised actions could be added to the EditForm.
|
* including that dataobject's extensions customised actions could be added to the EditForm.
|
||||||
*
|
*
|
||||||
* @return an Empty FieldSet(); need to be overload by solid subclass
|
* @return an Empty FieldList(); need to be overload by solid subclass
|
||||||
*/
|
*/
|
||||||
public function getCMSActions() {
|
public function getCMSActions() {
|
||||||
$actions = new FieldList();
|
$actions = new FieldList();
|
||||||
@ -1906,7 +1906,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
* @todo Decide on naming for "website|frontend|site|page" and stick with it in the API
|
* @todo Decide on naming for "website|frontend|site|page" and stick with it in the API
|
||||||
*
|
*
|
||||||
* @param array $params See {@link scaffoldFormFields()}
|
* @param array $params See {@link scaffoldFormFields()}
|
||||||
* @return FieldSet Always returns a simple field collection without TabSet.
|
* @return FieldList Always returns a simple field collection without TabSet.
|
||||||
*/
|
*/
|
||||||
public function getFrontEndFields($params = null) {
|
public function getFrontEndFields($params = null) {
|
||||||
$untabbedFields = $this->scaffoldFormFields($params);
|
$untabbedFields = $this->scaffoldFormFields($params);
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
* search results, e.g. in a {@link TableListField} instance.
|
* search results, e.g. in a {@link TableListField} instance.
|
||||||
*
|
*
|
||||||
* In case you need multiple contexts, consider namespacing your request parameters
|
* In case you need multiple contexts, consider namespacing your request parameters
|
||||||
* by using {@link FieldSet->namespace()} on the $fields constructor parameter.
|
* by using {@link FieldList->namespace()} on the $fields constructor parameter.
|
||||||
*
|
*
|
||||||
* Each DataObject subclass can have multiple search contexts for different cases,
|
* Each DataObject subclass can have multiple search contexts for different cases,
|
||||||
* e.g. for a limited frontend search and a fully featured backend search.
|
* e.g. for a limited frontend search and a fully featured backend search.
|
||||||
@ -37,7 +37,7 @@ class SearchContext extends Object {
|
|||||||
* FormFields mapping to {@link DataObject::$db} properties
|
* FormFields mapping to {@link DataObject::$db} properties
|
||||||
* which are supposed to be searchable.
|
* which are supposed to be searchable.
|
||||||
*
|
*
|
||||||
* @var FieldSet
|
* @var FieldList
|
||||||
*/
|
*/
|
||||||
protected $fields;
|
protected $fields;
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ class SearchContext extends Object {
|
|||||||
/**
|
/**
|
||||||
* Returns scaffolded search fields for UI.
|
* Returns scaffolded search fields for UI.
|
||||||
*
|
*
|
||||||
* @return FieldSet
|
* @return FieldList
|
||||||
*/
|
*/
|
||||||
public function getSearchFields() {
|
public function getSearchFields() {
|
||||||
return ($this->fields) ? $this->fields : singleton($this->modelClass)->scaffoldSearchFields();
|
return ($this->fields) ? $this->fields : singleton($this->modelClass)->scaffoldSearchFields();
|
||||||
@ -232,7 +232,7 @@ class SearchContext extends Object {
|
|||||||
/**
|
/**
|
||||||
* Get the list of searchable fields in the current search context.
|
* Get the list of searchable fields in the current search context.
|
||||||
*
|
*
|
||||||
* @return FieldSet
|
* @return FieldList
|
||||||
*/
|
*/
|
||||||
public function getFields() {
|
public function getFields() {
|
||||||
return $this->fields;
|
return $this->fields;
|
||||||
|
@ -13,11 +13,11 @@ class ChangePasswordForm extends Form {
|
|||||||
* create the appropriate form action tag.
|
* create the appropriate form action tag.
|
||||||
* @param string $name The method on the controller that will return this
|
* @param string $name The method on the controller that will return this
|
||||||
* form object.
|
* form object.
|
||||||
* @param FieldSet|FormField $fields All of the fields in the form - a
|
* @param FieldList|FormField $fields All of the fields in the form - a
|
||||||
* {@link FieldSet} of {@link FormField}
|
* {@link FieldList} of {@link FormField}
|
||||||
* objects.
|
* objects.
|
||||||
* @param FieldSet|FormAction $actions All of the action buttons in the
|
* @param FieldList|FormAction $actions All of the action buttons in the
|
||||||
* form - a {@link FieldSet} of
|
* form - a {@link FieldList} of
|
||||||
*/
|
*/
|
||||||
function __construct($controller, $name, $fields = null, $actions = null) {
|
function __construct($controller, $name, $fields = null, $actions = null) {
|
||||||
if(isset($_REQUEST['BackURL'])) {
|
if(isset($_REQUEST['BackURL'])) {
|
||||||
|
@ -57,7 +57,7 @@ class Group extends DataObject {
|
|||||||
/**
|
/**
|
||||||
* Caution: Only call on instances, not through a singleton.
|
* Caution: Only call on instances, not through a singleton.
|
||||||
*
|
*
|
||||||
* @return FieldSet
|
* @return FieldList
|
||||||
*/
|
*/
|
||||||
public function getCMSFields() {
|
public function getCMSFields() {
|
||||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/PermissionCheckboxSetField.js');
|
Requirements::javascript(SAPPHIRE_DIR . '/javascript/PermissionCheckboxSetField.js');
|
||||||
|
@ -504,7 +504,7 @@ class Member extends DataObject {
|
|||||||
* Returns the fields for the member form - used in the registration/profile module.
|
* Returns the fields for the member form - used in the registration/profile module.
|
||||||
* It should return fields that are editable by the admin and the logged-in user.
|
* It should return fields that are editable by the admin and the logged-in user.
|
||||||
*
|
*
|
||||||
* @return FieldSet Returns a {@link FieldSet} containing the fields for
|
* @return FieldList Returns a {@link FieldList} containing the fields for
|
||||||
* the member form.
|
* the member form.
|
||||||
*/
|
*/
|
||||||
public function getMemberFormFields() {
|
public function getMemberFormFields() {
|
||||||
@ -1091,10 +1091,10 @@ class Member extends DataObject {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a {@link FieldSet} of fields that would appropriate for editing
|
* Return a {@link FieldList} of fields that would appropriate for editing
|
||||||
* this member.
|
* this member.
|
||||||
*
|
*
|
||||||
* @return FieldSet Return a FieldSet of fields that would appropriate for
|
* @return FieldList Return a FieldList of fields that would appropriate for
|
||||||
* editing this member.
|
* editing this member.
|
||||||
*/
|
*/
|
||||||
public function getCMSFields() {
|
public function getCMSFields() {
|
||||||
|
@ -21,11 +21,11 @@ class MemberLoginForm extends LoginForm {
|
|||||||
* create the appropriate form action tag.
|
* create the appropriate form action tag.
|
||||||
* @param string $name The method on the controller that will return this
|
* @param string $name The method on the controller that will return this
|
||||||
* form object.
|
* form object.
|
||||||
* @param FieldSet|FormField $fields All of the fields in the form - a
|
* @param FieldList|FormField $fields All of the fields in the form - a
|
||||||
* {@link FieldSet} of {@link FormField}
|
* {@link FieldList} of {@link FormField}
|
||||||
* objects.
|
* objects.
|
||||||
* @param FieldSet|FormAction $actions All of the action buttons in the
|
* @param FieldList|FormAction $actions All of the action buttons in the
|
||||||
* form - a {@link FieldSet} of
|
* form - a {@link FieldList} of
|
||||||
* {@link FormAction} objects
|
* {@link FormAction} objects
|
||||||
* @param bool $checkCurrentUser If set to TRUE, it will be checked if a
|
* @param bool $checkCurrentUser If set to TRUE, it will be checked if a
|
||||||
* the user is currently logged in, and if
|
* the user is currently logged in, and if
|
||||||
|
Loading…
Reference in New Issue
Block a user