diff --git a/resources/lang/en/messages.php b/resources/lang/en/messages.php index 324478e73c..b4c985c413 100644 --- a/resources/lang/en/messages.php +++ b/resources/lang/en/messages.php @@ -93,6 +93,7 @@ 'fields_instructions_instructions' => 'Provide additional field instructions like this very text. Markdown formatting is supported.', 'fields_instructions_position_instructions' => 'Show instructions above or below the field.', 'fields_listable_instructions' => 'Control the listing column visibility.', + 'fields_sortable_instructions' => 'Control if the field should be sortable in listing views.', 'fields_visibility_instructions' => 'Control field visibility on publish forms.', 'fields_replicator_preview_instructions' => 'Control preview visibility in Replicator/Bard sets.', 'fieldset_import_fieldset_instructions' => 'The fieldset to be imported.', diff --git a/src/Fields/Field.php b/src/Fields/Field.php index 8f3ef80e9a..9afc042d35 100644 --- a/src/Fields/Field.php +++ b/src/Fields/Field.php @@ -533,6 +533,12 @@ public static function commonFieldOptions(): Fields 'type' => 'section', ], ], + 'sortable' => [ + 'display' => __('Sortable'), + 'instructions' => __('statamic::messages.fields_sortable_instructions'), + 'type' => 'toggle', + 'default' => true, + ], 'visibility' => [ 'display' => __('Visibility'), 'instructions' => __('statamic::messages.fields_visibility_instructions'), diff --git a/tests/Fields/BlueprintTest.php b/tests/Fields/BlueprintTest.php index 45f700b0f2..723fa64f2d 100644 --- a/tests/Fields/BlueprintTest.php +++ b/tests/Fields/BlueprintTest.php @@ -432,6 +432,7 @@ public function converts_to_array_suitable_for_rendering_fields_in_publish_compo 'instructions' => 'One instructions', 'instructions_position' => 'above', 'listable' => 'hidden', + 'sortable' => true, 'visibility' => 'visible', 'replicator_preview' => true, 'duplicate' => true, @@ -469,6 +470,7 @@ public function converts_to_array_suitable_for_rendering_fields_in_publish_compo 'instructions' => 'Two instructions', 'instructions_position' => 'above', 'listable' => 'hidden', + 'sortable' => true, 'visibility' => 'visible', 'replicator_preview' => true, 'duplicate' => true, @@ -557,6 +559,7 @@ public function converts_to_array_suitable_for_rendering_prefixed_conditional_fi 'instructions' => null, 'instructions_position' => 'above', 'listable' => 'hidden', + 'sortable' => true, 'visibility' => 'visible', 'replicator_preview' => true, 'duplicate' => true, @@ -582,6 +585,7 @@ public function converts_to_array_suitable_for_rendering_prefixed_conditional_fi 'instructions' => null, 'instructions_position' => 'above', 'listable' => 'hidden', + 'sortable' => true, 'visibility' => 'visible', 'replicator_preview' => true, 'duplicate' => true, diff --git a/tests/Fields/FieldTest.php b/tests/Fields/FieldTest.php index 7cb6272062..62c9221748 100644 --- a/tests/Fields/FieldTest.php +++ b/tests/Fields/FieldTest.php @@ -338,6 +338,7 @@ public function preProcess($data) 'instructions' => 'Test instructions', 'instructions_position' => 'below', 'listable' => 'hidden', + 'sortable' => true, 'visibility' => 'visible', 'replicator_preview' => true, 'duplicate' => true, diff --git a/tests/Fields/FieldsTest.php b/tests/Fields/FieldsTest.php index 80ab5aea95..057bc08d2a 100644 --- a/tests/Fields/FieldsTest.php +++ b/tests/Fields/FieldsTest.php @@ -431,6 +431,7 @@ public function converts_to_array_suitable_for_rendering_fields_in_publish_compo 'hide_display' => false, 'instructions_position' => 'above', 'listable' => 'hidden', + 'sortable' => true, 'replicator_preview' => true, 'duplicate' => true, ], @@ -453,6 +454,7 @@ public function converts_to_array_suitable_for_rendering_fields_in_publish_compo 'hide_display' => false, 'instructions_position' => 'above', 'listable' => 'hidden', + 'sortable' => true, 'replicator_preview' => true, 'duplicate' => true, ], @@ -517,6 +519,7 @@ public function converts_to_array_suitable_for_rendering_prefixed_conditional_fi 'hide_display' => false, 'instructions_position' => 'above', 'listable' => 'hidden', + 'sortable' => true, 'replicator_preview' => true, 'duplicate' => true, ], @@ -542,6 +545,7 @@ public function converts_to_array_suitable_for_rendering_prefixed_conditional_fi 'hide_display' => false, 'instructions_position' => 'above', 'listable' => 'hidden', + 'sortable' => true, 'replicator_preview' => true, 'duplicate' => true, ], diff --git a/tests/Fields/SectionTest.php b/tests/Fields/SectionTest.php index 146b7806fc..bbfcdf3591 100644 --- a/tests/Fields/SectionTest.php +++ b/tests/Fields/SectionTest.php @@ -121,6 +121,7 @@ public function converts_to_array_suitable_for_rendering_fields_in_publish_compo 'instructions' => 'One instructions', 'instructions_position' => 'above', 'listable' => 'hidden', + 'sortable' => true, 'visibility' => 'visible', 'replicator_preview' => true, 'duplicate' => true, @@ -147,6 +148,7 @@ public function converts_to_array_suitable_for_rendering_fields_in_publish_compo 'instructions' => 'Two instructions', 'instructions_position' => 'above', 'listable' => 'hidden', + 'sortable' => true, 'visibility' => 'visible', 'replicator_preview' => true, 'duplicate' => true, diff --git a/tests/Fields/TabTest.php b/tests/Fields/TabTest.php index d9dcb949b1..28940fec67 100644 --- a/tests/Fields/TabTest.php +++ b/tests/Fields/TabTest.php @@ -146,6 +146,7 @@ public function converts_to_array_suitable_for_rendering_fields_in_publish_compo 'instructions' => 'One instructions', 'instructions_position' => 'above', 'listable' => 'hidden', + 'sortable' => true, 'visibility' => 'visible', 'replicator_preview' => true, 'duplicate' => true, @@ -172,6 +173,7 @@ public function converts_to_array_suitable_for_rendering_fields_in_publish_compo 'instructions' => 'Two instructions', 'instructions_position' => 'above', 'listable' => 'hidden', + 'sortable' => true, 'visibility' => 'visible', 'replicator_preview' => true, 'duplicate' => true, diff --git a/tests/Fieldtypes/NestedFieldsTest.php b/tests/Fieldtypes/NestedFieldsTest.php index 59d1c39ad1..d35817067a 100644 --- a/tests/Fieldtypes/NestedFieldsTest.php +++ b/tests/Fieldtypes/NestedFieldsTest.php @@ -80,6 +80,7 @@ public function preProcess($data) 'instructions' => 'Some instructions', 'instructions_position' => 'above', 'listable' => 'hidden', + 'sortable' => true, 'visibility' => 'visible', 'replicator_preview' => true, 'duplicate' => true, diff --git a/tests/Fieldtypes/SetsTest.php b/tests/Fieldtypes/SetsTest.php index d0e4c69296..4906616203 100644 --- a/tests/Fieldtypes/SetsTest.php +++ b/tests/Fieldtypes/SetsTest.php @@ -219,6 +219,7 @@ public function it_preprocesses_for_config_with_groups() 'instructions' => null, 'instructions_position' => 'above', 'listable' => 'hidden', + 'sortable' => true, 'visibility' => 'visible', 'replicator_preview' => true, 'duplicate' => true, @@ -255,6 +256,7 @@ public function it_preprocesses_for_config_with_groups() 'instructions' => null, 'instructions_position' => 'above', 'listable' => 'hidden', + 'sortable' => true, 'visibility' => 'visible', 'replicator_preview' => true, 'duplicate' => true, @@ -314,6 +316,7 @@ public function it_preprocesses_for_config_without_groups() 'instructions' => null, 'instructions_position' => 'above', 'listable' => 'hidden', + 'sortable' => true, 'visibility' => 'visible', 'replicator_preview' => true, 'duplicate' => true,