Skip to content

Commit

Permalink
[4.x] Fix date field not populating with current date, revert prevent…
Browse files Browse the repository at this point in the history
…ion of ensuring fields if they already exist (#9094)
  • Loading branch information
jasonvarga authored Nov 30, 2023
1 parent 1325025 commit 3757201
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/Entries/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,22 +338,20 @@ public function fallbackEntryBlueprint()

public function ensureEntryBlueprintFields($blueprint)
{
if (! $blueprint->hasField('title')) {
$blueprint->ensureFieldPrepended('title', [
'type' => ($auto = $this->autoGeneratesTitles()) ? 'hidden' : 'text',
'required' => ! $auto,
]);
}
$blueprint->ensureFieldPrepended('title', [
'type' => ($auto = $this->autoGeneratesTitles()) ? 'hidden' : 'text',
'required' => ! $auto,
]);

if ($this->requiresSlugs() && ! $blueprint->hasField('slug')) {
if ($this->requiresSlugs()) {
$blueprint->ensureField('slug', ['type' => 'slug', 'localizable' => true, 'validate' => 'max:200'], 'sidebar');
}

if ($this->dated() && ! $blueprint->hasField('date')) {
if ($this->dated()) {
$blueprint->ensureField('date', ['type' => 'date', 'required' => true, 'default' => 'now'], 'sidebar');
}

if ($this->hasStructure() && ! $this->orderable() && ! $blueprint->hasField('parent')) {
if ($this->hasStructure() && ! $this->orderable()) {
$blueprint->ensureField('parent', [
'type' => 'entries',
'collections' => [$this->handle()],
Expand Down

0 comments on commit 3757201

Please sign in to comment.