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] Merge config field defaults into field config #10139

Merged
merged 12 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
9 changes: 7 additions & 2 deletions src/Fields/Fieldtype.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,14 @@ public function config(?string $key = null, $fallback = null)
return $fallback;
}

$config = $this->configFields()->all()
->map->get('default')
->filter()
->merge($this->field->config());

return $key
? $this->field->get($key, $fallback)
: $this->field->config();
? $config->get($key, $fallback)
: $config->all();
}

public function preload()
Expand Down
10 changes: 5 additions & 5 deletions tests/Fieldtypes/MarkdownTest.php
jasonvarga marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function it_can_automatically_add_line_breaks_when_augmenting()
EOT;

$default = $this->fieldtype();
$this->assertEqualsTrimmed($withoutBreaks, $default->augment($value));
$this->assertEqualsTrimmed($withBreaks, $default->augment($value));

$enabled = $this->fieldtype(['automatic_line_breaks' => true]);
$this->assertEqualsTrimmed($withBreaks, $enabled->augment($value));
Expand Down Expand Up @@ -156,12 +156,12 @@ public function it_converts_statamic_asset_urls()

$expected = <<<'EOT'
<h1>Actual asset...</h1>
<p><a href="/assets/foo/hoff.jpg">link</a>
<img src="/assets/foo/hoff.jpg" alt="" />
<p><a href="/assets/foo/hoff.jpg">link</a><br />
<img src="/assets/foo/hoff.jpg" alt="" /><br />
<img src="/assets/foo/hoff.jpg" alt="Asset" /></p>
<h1>Non-existent asset...</h1>
<p><a href="">link</a>
<img src="" alt="" />
<p><a href="">link</a><br />
<img src="" alt="" /><br />
<a href="">Asset Link</a></p>

EOT;
Expand Down
Loading