Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x] Drop default values from fieldtypes #10272

Merged
merged 4 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/Fieldtypes/Assets/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
class Assets extends Fieldtype
{
protected $categories = ['media', 'relationship'];
protected $defaultValue = [];
protected $selectableInForms = true;

protected function configFieldItems(): array
Expand Down
1 change: 0 additions & 1 deletion src/Fieldtypes/Bard.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class Bard extends Replicator
];

protected $categories = ['text', 'structured'];
protected $defaultValue = [];
protected $rules = [];

protected function configFieldItems(): array
Expand Down
1 change: 0 additions & 1 deletion src/Fieldtypes/Files.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

class Files extends Fieldtype
{
protected $defaultValue = [];
protected $selectable = false;
protected $selectableInForms = true;
protected $categories = ['media'];
Expand Down
1 change: 0 additions & 1 deletion src/Fieldtypes/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class Grid extends Fieldtype
{
protected $categories = ['structured'];
protected $defaultable = false;
protected $defaultValue = [];

protected function configFieldItems(): array
{
Expand Down
1 change: 0 additions & 1 deletion src/Fieldtypes/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class Group extends Fieldtype
{
protected $categories = ['structured'];
protected $defaultable = false;
protected $defaultValue = [];

protected function configFieldItems(): array
{
Expand Down
1 change: 0 additions & 1 deletion src/Fieldtypes/Relationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ abstract class Relationship extends Fieldtype
protected $canSearch = false;
protected $statusIcons = false;
protected $taggable = false;
protected $defaultValue = [];
protected $formComponentProps = [
'_' => '_', // forces an object in js
];
Expand Down
1 change: 0 additions & 1 deletion src/Fieldtypes/Replicator.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
class Replicator extends Fieldtype
{
protected $categories = ['structured'];
protected $defaultValue = [];
protected $rules = ['array'];

protected function configFieldItems(): array
Expand Down
12 changes: 9 additions & 3 deletions tests/Fields/FieldtypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,12 @@ public function no_pre_processing_happens_by_default_for_the_index()
/** @test */
public function it_gets_a_config_value()
{
(new class extends Fieldtype
{
protected static $handle = 'fieldtype_with_array_default';
protected $defaultValue = [];
})::register();

$field = new Field('test', [
'foo' => 'bar', // doesn't exist as a config field
'alfa' => 'overridden', // doesn't have a default
Expand All @@ -517,7 +523,7 @@ public function it_gets_a_config_value()
'delta' => false, // No default set
'echo' => true, // Default set
'foxtrot' => false, // Default set
// Files fields (has default of empty array)
// Test fields (has default of empty array)
'golf' => [], // No default set
'hotel' => ['hotel!'], // Default set
], $fieldtype->config());
Expand Down Expand Up @@ -595,10 +601,10 @@ class TestFieldtypeWithConfigFields extends Fieldtype
'default' => false,
],
'golf' => [
'type' => 'files',
'type' => 'fieldtype_with_array_default',
],
'hotel' => [
'type' => 'files',
'type' => 'fieldtype_with_array_default',
'default' => ['hotel!'],
],
];
Expand Down
Loading