Answers.Body: <blockquote>
    <p>Is this something that can be done with the Craft page when saving an entry?</p>
  </blockquote>
  
  <p>In 2.2, there isn't an easy way.  In the upcoming 2.3 release, we added a <code>$performAction</code> property to the event, so your can do something like:</p>
  
  <pre><code>$entry-&gt;addError('attribute', 'MyErrorMessage');
  $event-&gt;performAction = false;
  </code></pre>
  
  <p>And Craft will not save the entry and return to the edit entry page to display any validation errors.</p>
  
  <p>You should post your second question as an entirely new question.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-28T16:43:56.970Z
Answers.Text: Ok, many thanks. Any news on when 2.3 will be available?
Answers.UserDisplayName: Neil Young
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-28T16:44:44.923Z
Answers.Text: Closer than you think!
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-28T16:46:34.250Z
Answers.Text: Good stuff! :-)
Answers.UserDisplayName: Neil Young
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-11T15:04:57.733Z
Answers.Text: I have managed to get the update installed and have added your code above but I still don't seem to be able to add custom error messages. Although the performAction flag does seem to stop the entry from saving. Any idea of how I can get your code above to work?
Answers.UserDisplayName: Neil Young
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-20T12:51:52.440Z
Answers.Text: @NeilYoung try `$event->params['entry']->addError('MyFieldHandle', 'MyErrorMessage');`
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-28T16:41:04.143Z
Answers.LastActivityDate: 2014-11-28T16:41:04.143Z
Answers.UserDisplayName: Brad Bell
Body: <p>I am new to Craft but loving its ease of use so far.</p>
  
  <p>I am having a problem however when setting up a plugin to display an error to the user when using the onBeforeSaveEntry hook when a user saves an entry. I am looking to determine the value of a field and then take the user back to the entry page and display an error to the user based on a certain selection. Is this something that can be done with the Craft page when saving an entry?</p>
  
Tags: <plugin-development>
Title: Displaying Error onBeforeSaveEntry
ThreadText: # Displaying Error onBeforeSaveEntry
  
  (Asked by: username_0 on 2014-11-28)
  
  I am new to Craft but loving its ease of use so far.
  
  I am having a problem however when setting up a plugin to display an error to the user when using the onBeforeSaveEntry hook when a user saves an entry. I am looking to determine the value of a field and then take the user back to the entry page and display an error to the user based on a certain selection. Is this something that can be done with the Craft page when saving an entry?
  
  **Tags:** plugin-development
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-11-28. Score: 0 | Accepted answer
  
  > Is this something that can be done with the Craft page when saving an entry?
  
  In 2.2, there isn't an easy way. In the upcoming 2.3 release, we added a `$performAction` property to the event, so your can do something like:
  
  ```
  $entry->addError('attribute', 'MyErrorMessage');
  $event->performAction = false;
  
  ```
  
  And Craft will not save the entry and return to the edit entry page to display any validation errors.
  
  You should post your second question as an entirely new question.
  
  > **Comments:**
  > **username_0**: Ok, many thanks. Any news on when 2.3 will be available?  
  > **username_1**: Closer than you think!  
  > **username_0**: Good stuff! :-)  
  > **username_0**: I have managed to get the update installed and have added your code above but I still don't seem to be able to add custom error messages. Although the performAction flag does seem to stop the entry from saving. Any idea of how I can get your code above to work?  
  > **username_2**: @username_0 try `$event->params['entry']->addError('MyFieldHandle', 'MyErrorMessage');`  
  
  ---
  
  