Skip to content

Commit

Permalink
Merge pull request #11236 from creative-commoners/pulls/5/deprecate-n…
Browse files Browse the repository at this point in the history
…on-array

API Deprecate passing non-arrays to FieldList methods
  • Loading branch information
GuySartorelli committed May 16, 2024
2 parents 7625b29 + 0ba85bc commit cd77301
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Forms/FieldList.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace SilverStripe\Forms;

use SilverStripe\ORM\ArrayList;
use SilverStripe\Dev\Deprecation;

/**
* A list designed to hold form field instances.
Expand Down Expand Up @@ -218,6 +219,10 @@ public function addFieldToTab($tabName, $field, $insertBefore = null)
*/
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
Expand Down Expand Up @@ -270,6 +275,10 @@ public function removeFieldFromTab($tabName, $fieldName)
*/
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
Expand Down

0 comments on commit cd77301

Please sign in to comment.