Skip to content

Commit e5565fb

Browse files
committed
feat: enhance field value handling in content.blade.php with type-specific logic
1 parent cbc7605 commit e5565fb

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed
Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,31 @@
11
@php
22
$fieldData = $payload['changes']['field_value'] ?? null;
3-
3+
$fieldType = $fieldData['field_type'] ?? 'text';
44
$fieldName = $fieldData['field_name'] ?? 'Unknown Field';
5+
6+
// Handle from value
57
$fromValue = $fieldData['from']['name']
68
?? $fieldData['from']['title']
79
?? $fieldData['from']
810
?? null;
11+
12+
// Handle to value
913
$toValue = $fieldData['to']['name']
1014
?? $fieldData['to']['title']
1115
?? $fieldData['to']
1216
?? null;
17+
18+
// Special handling for boolean values
19+
if ($fieldType === 'checkbox') {
20+
$fromValue = filter_var($fromValue, FILTER_VALIDATE_BOOLEAN);
21+
$toValue = filter_var($toValue, FILTER_VALIDATE_BOOLEAN);
22+
}
23+
24+
// Check if template exists, fallback to unsupported
25+
$template = "github-project::md.field_types.{$fieldType}";
26+
if (!view()->exists($template)) {
27+
$template = 'github-project::md.field_types.unsupported';
28+
}
1329
@endphp
14-
@include(
15-
'github-project::md.field_types.' . $fieldData['field_type'],
16-
compact('fieldName', 'fromValue', 'toValue', 'fieldData')
17-
)
30+
31+
@include($template, compact('fieldName', 'fromValue', 'toValue', 'fieldData'))

0 commit comments

Comments
 (0)