Skip to content

Commit

Permalink
Merge pull request #3516 from bolt/feature/set-list-format-when-saving
Browse files Browse the repository at this point in the history
Set list_format in ContentEditController save function
  • Loading branch information
nestordedios committed Jan 29, 2024
2 parents 371451f + abd9e2e commit 17d1ee1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/Controller/Backend/ContentEditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,12 @@ public function save(?Content $originalContent = null, ?ContentValidatorInterfac
$this->em->persist($content);
$this->em->flush();

// Set the list_format of the Record in the bolt_content table. This has to be done in a 2nd iteration because
// $content does not have id set untill the Entity Manager is flushed.
$content->setListFormat();
$this->em->persist($content);
$this->em->flush();

$urlParams = [
'id' => $content->getId(),
'edit_locale' => $this->getEditLocale($content) ?: null,
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ public function setListFormat(): self
if ($this->contentExtension instanceof ContentExtension) {
$this->listFormat = Excerpt::getExcerpt($this->getExtras()['listFormat'], 191);
} else {
$this->title = '';
$this->listFormat = '';
}

return $this;
Expand Down

0 comments on commit 17d1ee1

Please sign in to comment.