code/extensions/FieldListExtension.php
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);
            }
        }
    }
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);
            }
        }
    }
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 ) ; } } }
Inserts a fields into a FieldList before a particular field if specified

@param array $fields An array of {@link FormField} objects.
@param FormField $item The form field to insert
Inserts a fields into a FieldList before a particular field if specified