Skip to content

Commit

Permalink
apply draft - element can be a response
Browse files Browse the repository at this point in the history
  • Loading branch information
i-just committed Jun 4, 2024
1 parent a41b83e commit 11ddae4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/controllers/ElementsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1634,9 +1634,14 @@ public function actionApplyDraft(): ?Response
$this->requirePostRequest();
$elementsService = Craft::$app->getElements();

/** @var Element|DraftBehavior|null $element */
/** @var Element|DraftBehavior|Response|null $element */
$element = $this->_element();

// this can happen if creating element via slideout, and we hit "create entry" before the autosave kicks in
if ($element instanceof Response) {
return $element;
}

if (!$element || !$element->getIsDraft()) {
throw new BadRequestHttpException('No draft was identified by the request.');
}
Expand Down

0 comments on commit 11ddae4

Please sign in to comment.