core/Form.php
public function addField(string $name, $field, string $before = null)
    {
        if ($field instanceof Field) {
            $field->name = $name;
        } else if (is_array($field)) {
            $field['name'] = $name;
            $field = new Field($this, $field);
        } else {
            return $this;
        }
        if (empty($field->boxName)) {
            $field->boxName = $field->name;
        }
        if (empty($field->boxId)) {
            $field->boxId = $field->boxName;
        }
        if (!empty($before) && isset($this->fields[$before])) {
            $temps = [];
            foreach ($this->fields as $key => $item) {
                if ($key == $before) {
                    $temps[$name] = $field;
                }
                $temps[$key] = $item;
            }
            $this->fields = $temps;
        } else {
            $this->fields[$name] = $field;
        }

        return $this;
    }
public function addField(string $name, $field, string $before = null)
    {
        if ($field instanceof Field) {
            $field->name = $name;
        } else if (is_array($field)) {
            $field['name'] = $name;
            $field = new Field($this, $field);
        } else {
            return $this;
        }
        if (empty($field->boxName)) {
            $field->boxName = $field->name;
        }
        if (empty($field->boxId)) {
            $field->boxId = $field->boxName;
        }
        if (!empty($before) && isset($this->fields[$before])) {
            $temps = [];
            foreach ($this->fields as $key => $item) {
                if ($key == $before) {
                    $temps[$name] = $field;
                }
                $temps[$key] = $item;
            }
            $this->fields = $temps;
        } else {
            $this->fields[$name] = $field;
        }

        return $this;
    }
添加字段
@param string $name
@param $field
@param string|null $before
@return $this