Skip to content

Commit

Permalink
On before draft bug
Browse files Browse the repository at this point in the history
  • Loading branch information
engram-design committed Feb 27, 2019
1 parent 83921e4 commit 247f199
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/services/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,13 @@ public function onBeforeSaveEntryDraft(DraftEvent $event)
$settings = Workflow::$plugin->getSettings();
$action = Craft::$app->getRequest()->getBodyParam('workflow-action');

$editorNotes = Craft::$app->getRequest()->getBodyParam('editorNotes');
$publisherNotes = Craft::$app->getRequest()->getBodyParam('publisherNotes');

if ($action === 'save-submission') {
// We also need to validate notes fields, if required before we save the entry
if ($settings->editorNotesRequired && !$editorNotes) {
$event->isValid = false;
$event->handled = true;

Craft::$app->getUrlManager()->setRouteParams([
'editorNotesErrors' => [Craft::t('workflow', 'Editor notes are required')],
Expand All @@ -95,11 +98,13 @@ public function onBeforeSaveEntryDraft(DraftEvent $event)
if ($action === 'approve-submission' || $action === 'reject-submission') {
// We also need to validate notes fields, if required before we save the entry
if ($settings->publisherNotesRequired && !$publisherNotes) {
$event->isValid = false;
$event->handled = true;

Craft::$app->getUrlManager()->setRouteParams([
'publisherNotesErrors' => [Craft::t('workflow', 'Publisher notes are required')],
]);

return false;
}
}
}
Expand Down

0 comments on commit 247f199

Please sign in to comment.