public function addFieldsBefore($fields, $insertBefore = null)
    {
        // $this->owner->flushFieldsCache();

        // Add the fields to the list
        foreach ($fields as $field) {
            if ($insertBefore) {
                $this->owner->insertBefore($insertBefore, $field);
            } elseif (($name = $field->getName()) && $this->owner->fieldByName($name)) {
                // It exists, so we need to replace the old one
                $this->owner->replaceField($field->getName(), $field);
            } else {
                $this->owner->push($field);
            }
        }
    }