| | |
| | | return implode(',', $values); |
| | | } |
| | | |
| | | protected function sanitizeTagList(array $values, array $field_config): array |
| | | { |
| | | if (!is_array($values)) { |
| | | return []; |
| | | } |
| | | |
| | | if (empty(array_filter($values, fn($value) => !empty($value)))) { |
| | | return []; |
| | | } |
| | | |
| | | if (!isset($field_config['fields']) || !is_array($field_config['fields'])) { |
| | | return []; |
| | | } |
| | | |
| | | $sanitized = []; |
| | | |
| | | foreach ($values as $row) { |
| | | if (!is_array($row)) { |
| | | continue; |
| | | } |
| | | |
| | | // Clean up field names (remove prefixes like "fieldname:0:email") |
| | | $temp = []; |
| | | foreach ($row as $key => $value) { |
| | | $key_parts = explode(':', $key); |
| | | $clean_key = $key_parts[array_key_last($key_parts)]; |
| | | $temp[$clean_key] = $value; |
| | | } |
| | | $row = $temp; |
| | | |
| | | // Sanitize each field |
| | | $clean_row = []; |
| | | foreach ($field_config['fields'] as $key => $subfield_config) { |
| | | if (!array_key_exists($key, $row)) { |
| | | continue; |
| | | } |
| | | |
| | | $subfield_config['name'] = $key; // For backwards compatibility |
| | | $clean_row[$key] = $this->sanitize($row[$key], $subfield_config); |
| | | } |
| | | |
| | | // Only add row if it has at least one non-empty value |
| | | if (!empty(array_filter($clean_row))) { |
| | | $sanitized[] = $clean_row; |
| | | } |
| | | } |
| | | |
| | | return $sanitized; |
| | | } |
| | | |
| | | protected function sanitizeRepeater(array $values, array $field_config):array |
| | | { |
| | | if (!is_array($values)) { |
| | |
| | | return $sanitized; |
| | | } |
| | | |
| | | protected function sanitizeGallery(array|string $value):string |
| | | protected function sanitizeUpload(array|string $value):string |
| | | { |
| | | if (empty($value)) { |
| | | return ''; |