Merge pull request #11236 from creative-commoners/pulls/5/deprecate-non-array

API Deprecate passing non-arrays to FieldList methods
This commit is contained in:
Guy Sartorelli 2024-05-17 09:52:29 +12:00 committed by GitHub
commit cd77301de1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,6 +3,7 @@
namespace SilverStripe\Forms;
use SilverStripe\ORM\ArrayList;
use SilverStripe\Dev\Deprecation;
/**
* A list designed to hold form field instances.
@ -218,6 +219,10 @@ class FieldList extends ArrayList
*/
public function addFieldsToTab($tabName, $fields, $insertBefore = null)
{
if (!is_array($fields)) {
Deprecation::notice('5.3.0', '$fields will need to be passed as an array in CMS 6', Deprecation::SCOPE_METHOD);
}
$this->flushFieldsCache();
// Find the tab
@ -270,6 +275,10 @@ class FieldList extends ArrayList
*/
public function removeFieldsFromTab($tabName, $fields)
{
if (!is_array($fields)) {
Deprecation::notice('5.3.0', '$fields will need to be passed as an array in CMS 6', Deprecation::SCOPE_METHOD);
}
$this->flushFieldsCache();
// Find the tab