public function getDataAsArray()
    {
        $fields = $this->getFields();

        if (!$fields) {
            return [];
        }

        $result = [];

        foreach ($fields as $field) {
            //ignore non-fields
            if (!$field instanceof AbstractFormField) {
                continue;
            }

            // if a field is disabled, we will ignore the field and only set an empty string as value
            if ($field->isDisabled()) {
                if (!array_key_exists($field->getName(), $result)) {
                    $result[$field->getName()] = '';
                }
                continue;
            }


            if ($field instanceof CheckBox) {
                $result[$field->getName()] = $field->isChecked() ? $field->getValue() : '';
            } elseif ($field instanceof RadioButton) {
                // if the field is not checked...
                if (!$field->isChecked()) {
                    // there was no other field with the same name yet
                    if (!array_key_exists($field->getName(), $result)) {
                        // then set the field with an empty value
                        $result[$field->getName()] = '';
                    }
                } // the field is checked
                else {
                    $result[$field->getName()] = $field->getValue();
                }
            } elseif ($field instanceof UploadField) {
                $value = $field->getValue();
                if (!$value ||
                    !isset($value['error']) ||
                    $value['error'] == UPLOAD_ERR_NO_FILE ||
                    empty($value['name'])
                ) {
                    continue;
                }
                $result[$field->getName()] = $value['name'];
            } elseif ($field instanceof AbstractFormField) {
                $result[$field->getName()] = $field->getValue();
            }
        }
        return $result;
    }