prepare($data['fields']) as $field) { $this->cgView->render('/admin/field_type/' . $field['view_name'] . ".php", $field); } } private function prepare(Collection $rawFields): array { $fields = []; $i = 0; foreach ($rawFields as $field) { $params = json_decode($field['params'], true); $viewName = \itguild\forms\app\models\InputTypeModel::getViewNameByTypeId($field['input_type_id']); if (!isset($fields[$field['name']])) { $fields[$field['name']] = [ 'name' => $field['name'], 'form' => new ActiveForm(), 'view_name' => $viewName, 'count' => $i, ]; } if ($field['input_type_id'] == InputTypeModel::RADIO_TYPE) { if (isset($fields[$field['name']]['value'])) { $fields[$field['name']]['value'] .= "\n" . $params['value']; } else { $fields[$field['name']]['value'] = $params['value']; } } elseif ($field['input_type_id'] == InputTypeModel::SELECT_TYPE) { $fields[$field['name']]['value'] = implode("\n", InputValueService::getInputValuesById($field['id'])); } else { $fields[$field['name']]['value'] = $params['value'] ?? null; $fields[$field['name']]['placeholder'] = $params['placeholder'] ?? null; } $i++; } return $fields; } }