Skip to content

Commit 82377fb

Browse files
committed
Move fields into blueprint ...
- Because I added the listable field to the blueprint for processing, I hadn't noticed it was also being output in the loop. - Might as well move the rest. Cleans up the vue.
1 parent 8a26e0a commit 82377fb

File tree

2 files changed

+37
-44
lines changed

2 files changed

+37
-44
lines changed

resources/js/components/fields/Settings.vue

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -53,53 +53,14 @@
5353
>
5454
<div class="publish-fields" v-show="activeTab === 'settings'" slot-scope="{ setFieldValue }">
5555

56-
<form-group
57-
handle="display"
58-
:display="__('Display')"
59-
:instructions="__('messages.fields_display_instructions')"
60-
width="50"
61-
autoselect
62-
:value="values.display"
63-
@input="updateField('display', $event, setFieldValue)"
64-
/>
65-
66-
<form-group
67-
handle="handle"
68-
:display="__('Handle')"
69-
:instructions="__('messages.fields_handle_instructions')"
70-
width="50"
71-
:value="values.handle"
72-
@input="updateField('handle', $event, setFieldValue); isHandleModified = true"
73-
/>
74-
75-
<form-group
76-
fieldtype="text"
77-
handle="instructions"
78-
:display="__('Instructions')"
79-
:instructions="__('messages.fields_instructions_instructions')"
80-
:value="values.instructions"
81-
@input="updateField('instructions', $event, setFieldValue)"
82-
/>
83-
84-
<form-group
85-
fieldtype="select"
86-
handle="listable"
87-
:display="__('Listable')"
88-
:instructions="__('messages.fields_listable_instructions')"
89-
:config="{ options: {
90-
hidden: __('Hidden by default'),
91-
true: __('Yes'),
92-
false: __('No')
93-
}}"
94-
:value="values.listable"
95-
@input="updateField('listable', $event, setFieldValue)"
96-
/>
97-
9856
<publish-fields
9957
v-if="blueprint.sections.length"
10058
class="w-full"
10159
:fields="blueprint.sections[0].fields"
102-
@updated="(handle, value) => updateField(handle, value, setFieldValue)"
60+
@updated="(handle, value) => {
61+
updateField(handle, value, setFieldValue);
62+
if (handle === 'handle') isHandleModified = true
63+
}"
10364
/>
10465

10566
</div>

src/Http/Controllers/CP/Fields/FieldsController.php

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,38 @@ public function update(Request $request)
7070

7171
protected function blueprint($blueprint)
7272
{
73-
return $blueprint->ensureField('listable', ['type' => 'select', 'cast_booleans' => true]);
73+
$prepends = collect([
74+
'display' => [
75+
'type' => 'text',
76+
'instructions' => __('statamic::messages.fields_display_instructions'),
77+
'width' => 50,
78+
],
79+
'handle' => [
80+
'type' => 'text',
81+
'instructions' => __('statamic::messages.fields_handle_instructions'),
82+
'width' => 50,
83+
],
84+
'instructions' => [
85+
'type' => 'text',
86+
'instructions' => __('statamic::messages.fields_instructions_instructions'),
87+
],
88+
'listable' => [
89+
'type' => 'select',
90+
'instructions' => __('statamic::messages.fields_listable_instructions'),
91+
'cast_booleans' => true,
92+
'width' => 50,
93+
'options' => [
94+
'hidden' => __('Hidden by default'),
95+
'true' => __('Yes'),
96+
'false' => __('No'),
97+
],
98+
]
99+
]);
100+
101+
foreach ($prepends->reverse() as $handle => $prepend) {
102+
$blueprint->ensureFieldPrepended($handle, $prepend);
103+
}
104+
105+
return $blueprint;
74106
}
75107
}

0 commit comments

Comments
 (0)