mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-02 06:09:00 +02:00
MINOR removeField(s)FromTab no longer creates a tab if it doesn't exist
This commit is contained in:
parent
599a4420bf
commit
7ed056ec50
@ -299,8 +299,10 @@ class FieldList extends ArrayList
|
|||||||
$this->flushFieldsCache();
|
$this->flushFieldsCache();
|
||||||
|
|
||||||
// Find the tab
|
// Find the tab
|
||||||
$tab = $this->findOrMakeTab($tabName);
|
$tab = $this->findTab($tabName);
|
||||||
$tab->removeByName($fieldName);
|
if ($tab) {
|
||||||
|
$tab->removeByName($fieldName);
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -318,11 +320,12 @@ class FieldList extends ArrayList
|
|||||||
$this->flushFieldsCache();
|
$this->flushFieldsCache();
|
||||||
|
|
||||||
// Find the tab
|
// Find the tab
|
||||||
$tab = $this->findOrMakeTab($tabName);
|
$tab = $this->findTab($tabName);
|
||||||
|
if ($tab) {
|
||||||
// Add the fields to the end of this set
|
// Add the fields to the end of this set
|
||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
$tab->removeByName($field);
|
$tab->removeByName($field);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@ -428,6 +431,28 @@ class FieldList extends ArrayList
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the specified tab object, if it exists
|
||||||
|
*
|
||||||
|
* @param string $tabName The tab to return, in the form "Tab.Subtab.Subsubtab".
|
||||||
|
* @return Tab|null The found or null
|
||||||
|
*/
|
||||||
|
public function findTab($tabName)
|
||||||
|
{
|
||||||
|
$parts = explode('.', $tabName);
|
||||||
|
$last_idx = count($parts) - 1;
|
||||||
|
|
||||||
|
$currentPointer = $this;
|
||||||
|
|
||||||
|
foreach ($parts as $k => $part) {
|
||||||
|
$parentPointer = $currentPointer;
|
||||||
|
/** @var FormField $currentPointer */
|
||||||
|
$currentPointer = $currentPointer->fieldByName($part);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $currentPointer;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the specified tab object, creating it if necessary.
|
* Returns the specified tab object, creating it if necessary.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user