lib/components/web/form/Segment.php
protected function getFields()
    {
        $settings = $this->settings;
        if (is_null($this->_fields)) {
            $this->_fields = [];
            if (is_array($settings)) {
                $this->_settings = $settings;
            } else {
                $this->_settings = [];
            }
            if (!isset($this->_settings['fieldSettings'])) {
                $this->_settings['fieldSettings'] = [];
            }
            if (!isset($this->_settings['formField'])) {
                $this->_settings['formField'] = [];
            }
            if (!isset($this->_settings['ignoreFields'])) {
                $this->_settings['ignoreFields'] = [];
            }
            if (is_array($this->_settings['fields']) && empty($this->_settings['fields'])) {
                $this->_settings['fields'] = null;
            }
            $fields = $this->_model->getFields($this);
            if (!isset($this->_model->_moduleHandler)) {
                $modelClass = get_class($this->_model);
                $this->_model->_moduleHandler = $modelClass::FORM_PRIMARY_MODEL;
            }
            $requiredFields = true;
            $fieldsTemplate = false;
            if (!is_null($this->relationField)) {
                $fieldName = $this->relationField->modelRole . ':' . $this->relationField->baseModel->objectType->systemId;
                if (isset($fields[$fieldName])) {
                    $fields[$fieldName]->baseModel = $this->relationField->baseModel;
                    $fields[$fieldName]->model = $this->relationField->model;
                    $fields[$fieldName]->formField = $this->relationField->formField;
                    $fields[$fieldName]->required = true;
                    $this->relationField->formField->inlineRelation = true;
                    if (!$this->relationField->model->isNewRecord && $this->relationField->companion->hasDashboard) {
                        $fieldsTemplate = [[$fieldName]];
                        $requiredFields = false;
                    }
                }
            }
            if ($requiredFields) {
                $requiredFields = $this->_model->getRequiredFields($this);
            } else {
                $requiredFields = [$fieldName => $fields[$fieldName]];
            }
            if (!$fieldsTemplate) {
                if (!empty($this->subform)) {
                    $fieldsTemplate = [[$this->subform => ['relationSettings' => $this->relationSettings]]];
                } elseif (!isset($this->_settings['fields'])) {
                    $fieldsTemplate = [];
                    foreach ($fields as $fieldName => $field) {
                        if (!$field->human) {
                            continue;
                        }
                        //if (!$field->required) { continue; }
                        if (!($field instanceof ModelField)) {
                            continue;
                        }
                        $fieldsTemplate[] = [$fieldName];
                    }
                } else {
                    $fieldsTemplate = $this->_settings['fields'];
                }
            }
            if ($fieldsTemplate !== false) {
                $this->_settings['fields'] = [];
                foreach ($fields as $fieldKey => $field) {
                    if (!is_object($field->model)) {
                        \d($field);
                        exit;
                    }
                    if ($field->model->isNewRecord) {
                        continue;
                    }
                    if ($field->human) {
                        continue;
                    }
                    if (!$field->required) {
                        continue;
                    }
                    $this->grid->prepend($field->formField);
                }
                $fields['_moduleHandler']->formField->owner = $this;
                $this->grid->prepend($fields['_moduleHandler']->formField);
                $cellClass = $this->cellClass;

                // make sure all required fields are part of the form
                if (empty($this->subform)) {
                    if (!empty($requiredFields)) {
                        foreach ($fieldsTemplate as $rowFields) {
                            foreach ($rowFields as $fieldKey => $fieldSettings) {
                                if (is_numeric($fieldKey)) {
                                    $fieldKey = $fieldSettings;
                                    $fieldSettings = [];
                                }
                                unset($requiredFields[$fieldKey]);
                            }
                        }
                    }

                    foreach ($requiredFields as $fieldName => $field) {
                        if (in_array($fieldName, $this->_settings['ignoreFields'])) {
                            continue;
                        }
                        $fieldsTemplate[] = [$fieldName];
                    }
                }

                foreach ($fieldsTemplate as $rowFields) {
                    $rowItems = [];
                    foreach ($rowFields as $fieldKey => $fieldSettings) {
                        if (is_numeric($fieldKey)) {
                            $fieldKey = $fieldSettings;
                            $fieldSettings = [];
                        }
                        if ($fieldKey === false || $fieldKey === ':empty') {
                            $rowItems[] = Yii::createObject(['class' => $cellClass, 'content' => '&nbsp;']);
                            continue;
                        }

                        if ($fieldKey === ':separator') {
                            $rowItems[] = Yii::createObject(['class' => $cellClass, 'content' => '<span class="separator"></span>']);
                            continue;
                        }

                        if (!isset($fields[$fieldKey])) {
                            \d([$fieldKey, array_keys($fields)]);
                            continue;
                        }

                        $this->_fields[$fieldKey] = $fields[$fieldKey];
                        if ($fieldKey === false) {
                            $rowItems[] = false;
                        } else {
                            //\d([$fieldKey, $fieldSettings]);
                            $cellOptions = ['class' => $cellClass, 'content' => $fields[$fieldKey]->formField->configure($fieldSettings)];
                            if (isset($cellOptions['content']->columns)) {
                                $cellOptions['columns'] = $cellOptions['content']->columns;
                            }
                            $rowItems[] = Yii::createObject($cellOptions);
                        }
                    }
                    $this->grid->addRow($rowItems);
                }
            }
        }
        //\d($this->_fields);exit;
        return $this->_fields;
    }
protected function getFields()
    {
        $settings = $this->settings;
        if (is_null($this->_fields)) {
            $this->_fields = [];
            if (is_array($settings)) {
                $this->_settings = $settings;
            } else {
                $this->_settings = [];
            }
            if (!isset($this->_settings['fieldSettings'])) {
                $this->_settings['fieldSettings'] = [];
            }
            if (!isset($this->_settings['formField'])) {
                $this->_settings['formField'] = [];
            }
            if (!isset($this->_settings['ignoreFields'])) {
                $this->_settings['ignoreFields'] = [];
            }
            if (is_array($this->_settings['fields']) && empty($this->_settings['fields'])) {
                $this->_settings['fields'] = null;
            }
            $fields = $this->_model->getFields($this);
            if (!isset($this->_model->_moduleHandler)) {
                $modelClass = get_class($this->_model);
                $this->_model->_moduleHandler = $modelClass::FORM_PRIMARY_MODEL;
            }
            $requiredFields = true;
            $fieldsTemplate = false;
            if (!is_null($this->relationField)) {
                $fieldName = $this->relationField->modelRole . ':' . $this->relationField->baseModel->objectType->systemId;
                if (isset($fields[$fieldName])) {
                    $fields[$fieldName]->baseModel = $this->relationField->baseModel;
                    $fields[$fieldName]->model = $this->relationField->model;
                    $fields[$fieldName]->formField = $this->relationField->formField;
                    $fields[$fieldName]->required = true;
                    $this->relationField->formField->inlineRelation = true;
                    if (!$this->relationField->model->isNewRecord && $this->relationField->companion->hasDashboard) {
                        $fieldsTemplate = [[$fieldName]];
                        $requiredFields = false;
                    }
                }
            }
            if ($requiredFields) {
                $requiredFields = $this->_model->getRequiredFields($this);
            } else {
                $requiredFields = [$fieldName => $fields[$fieldName]];
            }
            if (!$fieldsTemplate) {
                if (!empty($this->subform)) {
                    $fieldsTemplate = [[$this->subform => ['relationSettings' => $this->relationSettings]]];
                } elseif (!isset($this->_settings['fields'])) {
                    $fieldsTemplate = [];
                    foreach ($fields as $fieldName => $field) {
                        if (!$field->human) {
                            continue;
                        }
                        //if (!$field->required) { continue; }
                        if (!($field instanceof ModelField)) {
                            continue;
                        }
                        $fieldsTemplate[] = [$fieldName];
                    }
                } else {
                    $fieldsTemplate = $this->_settings['fields'];
                }
            }
            if ($fieldsTemplate !== false) {
                $this->_settings['fields'] = [];
                foreach ($fields as $fieldKey => $field) {
                    if (!is_object($field->model)) {
                        \d($field);
                        exit;
                    }
                    if ($field->model->isNewRecord) {
                        continue;
                    }
                    if ($field->human) {
                        continue;
                    }
                    if (!$field->required) {
                        continue;
                    }
                    $this->grid->prepend($field->formField);
                }
                $fields['_moduleHandler']->formField->owner = $this;
                $this->grid->prepend($fields['_moduleHandler']->formField);
                $cellClass = $this->cellClass;

                // make sure all required fields are part of the form
                if (empty($this->subform)) {
                    if (!empty($requiredFields)) {
                        foreach ($fieldsTemplate as $rowFields) {
                            foreach ($rowFields as $fieldKey => $fieldSettings) {
                                if (is_numeric($fieldKey)) {
                                    $fieldKey = $fieldSettings;
                                    $fieldSettings = [];
                                }
                                unset($requiredFields[$fieldKey]);
                            }
                        }
                    }

                    foreach ($requiredFields as $fieldName => $field) {
                        if (in_array($fieldName, $this->_settings['ignoreFields'])) {
                            continue;
                        }
                        $fieldsTemplate[] = [$fieldName];
                    }
                }

                foreach ($fieldsTemplate as $rowFields) {
                    $rowItems = [];
                    foreach ($rowFields as $fieldKey => $fieldSettings) {
                        if (is_numeric($fieldKey)) {
                            $fieldKey = $fieldSettings;
                            $fieldSettings = [];
                        }
                        if ($fieldKey === false || $fieldKey === ':empty') {
                            $rowItems[] = Yii::createObject(['class' => $cellClass, 'content' => '&nbsp;']);
                            continue;
                        }

                        if ($fieldKey === ':separator') {
                            $rowItems[] = Yii::createObject(['class' => $cellClass, 'content' => '<span class="separator"></span>']);
                            continue;
                        }

                        if (!isset($fields[$fieldKey])) {
                            \d([$fieldKey, array_keys($fields)]);
                            continue;
                        }

                        $this->_fields[$fieldKey] = $fields[$fieldKey];
                        if ($fieldKey === false) {
                            $rowItems[] = false;
                        } else {
                            //\d([$fieldKey, $fieldSettings]);
                            $cellOptions = ['class' => $cellClass, 'content' => $fields[$fieldKey]->formField->configure($fieldSettings)];
                            if (isset($cellOptions['content']->columns)) {
                                $cellOptions['columns'] = $cellOptions['content']->columns;
                            }
                            $rowItems[] = Yii::createObject($cellOptions);
                        }
                    }
                    $this->grid->addRow($rowItems);
                }
            }
        }
        //\d($this->_fields);exit;
        return $this->_fields;
    }
Get fields.

@return unknown