Skip to content

Commit afcb67e

Browse files
authored
Merge pull request #25 from webfactor/fix_option_label
Fix option label in ajax select2 fields.
2 parents 5c070e3 + 1f2944c commit afcb67e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

resources/views/fields/select2_from_ajax.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
@endif
3131

3232
<option value="{{ $item->getKey() }}" selected>
33-
{{ $item->{ $field['value'] ?? $field['attribute']} }}
33+
{{ $item->{isset($field['option_label']) ? $field['option_label'] : $field['attribute']} }}
3434
</option>
3535
@endif
3636
@endif
@@ -113,7 +113,7 @@
113113
var result = {
114114
results: $.map(data.data, function (item) {
115115
return {
116-
text: item["{{ $field['value'] ?? $field['attribute'] }}"],
116+
text: item["{{ isset($field['option_label']) ? $field['option_label'] : $field['attribute'] }}"],
117117
id: item["{{ $connected_entity_key_name }}"]
118118
}
119119
}),

resources/views/fields/select2_from_ajax_multiple.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
@endphp
2424
@endif
2525
<option value="{{ $item->getKey() }}" selected>
26-
{{ $item->{$field['value'] ?? $field['attribute']} }}
26+
{{ $item->{isset($field['option_label']) ? $field['option_label'] : $field['attribute']} }}
2727
</option>
2828
@endforeach
2929
@endif
@@ -92,7 +92,7 @@
9292
return {
9393
results: $.map(data.data, function (item) {
9494
return {
95-
text: item["{{ $field['value'] ?? $field['attribute'] }}"],
95+
text: item["{{ isset($field['option_label']) ? $field['option_label'] : $field['attribute'] }}"],
9696
id: item["{{ $connected_entity_key_name }}"]
9797
}
9898
}),

0 commit comments

Comments
 (0)