| @@ -190,10 +190,11 @@ | ||
| 190 | 190 | foreach ($fields as $fieldData) { |
| 191 | 191 | $fieldData['formId'] = $fieldData['formId'] ?? $formId; |
| 192 | 192 | // Resolve parentId using fieldIndex if available |
| 193 | 193 | FieldHelper::resolveParentId($fieldData, $parentMap); |
| 194 | - // Process htmlContent to upload base64 images | |
| 194 | + // Process htmlContent / rich text default values to upload base64 images | |
| 195 | 195 | FieldHelper::processFieldHtmlContent($fieldData, $this->imageService); |
| 196 | + FieldHelper::processRichTextDefaultValue($fieldData, $this->imageService); | |
| 196 | 197 | $field = FieldFactory::create($fieldData); |
| 197 | 198 | $fieldId = $this->addField($field); |
| 198 | 199 | // If this is a parent field (no parentId), store its DB id in the map |
| 199 | 200 | if ($field->getParentId() === null) { |
| @@ -223,10 +224,11 @@ | ||
| 223 | 224 | $parentMap = []; |
| 224 | 225 | foreach ($fields as $fieldData) { |
| 225 | 226 | $fieldData['formId'] = $fieldData['formId'] ?? $formId; |
| 226 | 227 | FieldHelper::resolveParentId($fieldData, $parentMap); |
| 227 | - // Process htmlContent to upload base64 images | |
| 228 | + // Process htmlContent / rich text default values to upload base64 images | |
| 228 | 229 | FieldHelper::processFieldHtmlContent($fieldData, $this->imageService); |
| 230 | + FieldHelper::processRichTextDefaultValue($fieldData, $this->imageService); | |
| 229 | 231 | $field = FieldFactory::create($fieldData); |
| 230 | 232 | $fieldId = $field->getId(); |
| 231 | 233 | |
| 232 | 234 | if ($fieldId === 0) { // new field |
| @@ -326,24 +328,7 @@ | ||
| 326 | 328 | * @throws InvalidArgumentException |
| 327 | 329 | */ |
| 328 | 330 | public function validateFieldsType(array $formFields): void |
| 329 | 331 | { |
| 330 | - // Validate field types | |
| 331 | - $allowedTypes = FieldType::getAllowedTypes(); | |
| 332 | - foreach ($formFields as $field) { | |
| 333 | - // Check if field is an instance of Field or array | |
| 334 | - $fieldType = $field instanceof Field ? $field->getType() : ($field['type'] ?? null); | |
| 335 | - | |
| 336 | - if ($fieldType === null) { | |
| 337 | - throw new InvalidArgumentException( | |
| 338 | - BackendStrings::getExceptionStrings()['invalid_field_type'] . ' (type not found)' | |
| 339 | - ); | |
| 340 | - } | |
| 341 | - | |
| 342 | - if (!in_array($fieldType, $allowedTypes, true)) { | |
| 343 | - throw new InvalidArgumentException( | |
| 344 | - BackendStrings::getExceptionStrings()['invalid_field_type'] . ' ' . $fieldType | |
| 345 | - ); | |
| 346 | - } | |
| 347 | - } | |
| 332 | + FieldType::validateFields($formFields); | |
| 348 | 333 | } |
| 349 | 334 | } |