src/Forms/FieldList.php
public function removeByName($fieldName, $dataFieldOnly = false)
    {
        if (!$fieldName) {
            user_error('FieldList::removeByName() was called with a blank field name.', E_USER_WARNING);
        }

        // Handle array syntax
        if (is_array($fieldName)) {
            foreach ($fieldName as $field) {
                $this->removeByName($field, $dataFieldOnly);
            }
            return $this;
        }

        $this->flushFieldsCache();
        foreach ($this as $i => $child) {
            $childName = $child->getName();
            if (!$childName) {
                $childName = $child->Title();
            }

            if (($childName == $fieldName) && (!$dataFieldOnly || $child->hasData())) {
                array_splice($this->items, $i, 1);
                break;
            } elseif ($child instanceof CompositeField) {
                $child->removeByName($fieldName, $dataFieldOnly);
            }
        }

        return $this;
    }
public function removeByName($fieldName, $dataFieldOnly = false)
    {
        if (!$fieldName) {
            user_error('FieldList::removeByName() was called with a blank field name.', E_USER_WARNING);
        }

        // Handle array syntax
        if (is_array($fieldName)) {
            foreach ($fieldName as $field) {
                $this->removeByName($field, $dataFieldOnly);
            }
            return $this;
        }

        $this->flushFieldsCache();
        foreach ($this as $i => $child) {
            $childName = $child->getName();
            if (!$childName) {
                $childName = $child->Title();
            }

            if (($childName == $fieldName) && (!$dataFieldOnly || $child->hasData())) {
                array_splice($this->items, $i, 1);
                break;
            } elseif ($child instanceof CompositeField) {
                $child->removeByName($fieldName, $dataFieldOnly);
            }
        }

        return $this;
    }
public function removeByName ( $ fieldName , $ dataFieldOnly = false ) { if ( ! $ fieldName ) { user_error ( 'FieldList::removeByName() was called with a blank field name.' , E_USER_WARNING ) ; } // Handle array syntax if ( is_array ( $ fieldName ) ) { foreach ( $ fieldName as $ field ) { $ this -> removeByName ( $ field , $ dataFieldOnly ) ; } return $ this ; } $ this -> flushFieldsCache ( ) ; foreach ( $ this as $ i => $ child ) { $ childName = $ child -> getName ( ) ; if ( ! $ childName ) { $ childName = $ child -> Title ( ) ; } if ( ( $ childName == $ fieldName ) && ( ! $ dataFieldOnly || $ child -> hasData ( ) ) ) { array_splice ( $ this -> items , $ i , 1 ) ; break ; } elseif ( $ child instanceof CompositeField ) { $ child -> removeByName ( $ fieldName , $ dataFieldOnly ) ; } } return $ this ; }
Remove a field or fields from this FieldList by Name.
The field could also be inside a CompositeField.

@param string|array $fieldName The name of, or an array with the field(s) or tab(s)
@param boolean $dataFieldOnly If this is true, then a field will only
be removed if it's a data field.  Dataless fields, such as tabs, will
be left as-is.

@return $this
Remove a field or fields from this FieldList by Name . The field could also be inside a CompositeField .