mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
ENHANCEMENT #6228 FieldSet::addFieldsToTab() now allows inserting before a field name for consistency with addFieldToTab()
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@114817 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
1ca5ea6fb4
commit
ec661a9886
@ -112,7 +112,7 @@ class FieldSet extends DataObjectSet {
|
||||
* This function will create any missing tabs.
|
||||
* @param array $fields An array of {@link FormField} objects.
|
||||
*/
|
||||
public function addFieldsToTab($tabName, $fields) {
|
||||
public function addFieldsToTab($tabName, $fields, $insertBefore = null) {
|
||||
$this->flushFieldsCache();
|
||||
|
||||
// Find the tab
|
||||
@ -121,7 +121,9 @@ class FieldSet extends DataObjectSet {
|
||||
// Add the fields to the end of this set
|
||||
foreach($fields as $field) {
|
||||
// Check if a field by the same name exists in this tab
|
||||
if($tab->fieldByName($field->Name())) {
|
||||
if($insertBefore) {
|
||||
$tab->insertBefore($field, $insertBefore);
|
||||
} elseif($tab->fieldByName($field->Name())) {
|
||||
// It exists, so we need to replace the old one
|
||||
$this->replaceField($field->Name(), $field);
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user