Answers.Body: <p>I've contacted Freeforms (Solspace). Unfortunately there is no solution for this problem (yet). Solspace told me:</p>
  
  <blockquote>
    <p>This functionality currently isn't possible with Freeform. It's something on our feature requests list though.</p>
  </blockquote>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-01T10:22:18.207Z
Answers.LastActivityDate: 2017-11-01T10:22:18.207Z
Answers.UserDisplayName: Mr. Sam
Answers.Body: <p>Never used Freeform before, but it looks like that <a href="https://solspace.com/craft/freeform/docs/events-and-hooks/#event-onbeforesave-form" rel="nofollow noreferrer">event</a> has a <code>model</code> param passed into it.</p>
  
  <p>You should be able to add errors to it like any other models in Craft.</p>
  
  <pre><code>craft()-&gt;on(
      "freeform_submissions.onBeforeSave",
      function (Event $event) {
  
          // Let Freeform know the form is not valid
          $event-&gt;performAction = false;
  
          $event-&gt;params['model']-&gt;addError('email', 'This email is already in use!');
      }
  );
  </code></pre>
  
  <p>This assumes that there is an 'email' attribute on the <code>Freeform_SubmissionModel</code> class and there is logic to display errors in your template similar to: <a href="https://craftcms.com/docs/templating/entry-form" rel="nofollow noreferrer">https://craftcms.com/docs/templating/entry-form</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-01T10:20:12.553Z
Answers.Text: Unfortunately this won't work.
Answers.UserDisplayName: Mr. Sam
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-25T21:51:00.347Z
Answers.LastActivityDate: 2017-10-25T21:51:00.347Z
Answers.UserDisplayName: Brad Bell
Body: <p>I've created a plugin that will check for a unique email address in the submissions of Freeform.
  Because I don't want this check to be done with Ajax, I use the Freeform hook 'onBeforeSave'.</p>
  
  <p>Whenever a email is already used, I want the user to know. I'm telling Freeforms that the form is not valid:</p>
  
  <pre><code>craft()-&gt;on(
      "freeform_submissions.onBeforeSave",
      function (Event $event) {
  
          // Let Freeform know the form is not valid
          $event-&gt;performAction = false;
      }
  );
  </code></pre>
  
  <p>Unfortunately I haven't found a way to communicate this to the frontend. It would be nice if I could set a Freeform error message.</p>
  
  <p>Any solutions?</p>
  
Tags: <error-message><plugin-freeform><freeform>
Title: Freeforms - add error
ThreadText: # Freeforms - add error
  
  (Asked by: username_0 on 2017-10-23)
  
  I've created a plugin that will check for a unique email address in the submissions of Freeform.
  Because I don't want this check to be done with Ajax, I use the Freeform hook 'onBeforeSave'.
  
  Whenever a email is already used, I want the user to know. I'm telling Freeforms that the form is not valid:
  
  ```
  craft()->on(
      "freeform_submissions.onBeforeSave",
      function (Event $event) {
  
          // Let Freeform know the form is not valid
          $event->performAction = false;
      }
  );
  
  ```
  
  Unfortunately I haven't found a way to communicate this to the frontend. It would be nice if I could set a Freeform error message.
  
  Any solutions?
  
  **Tags:** error-message, plugin-freeform, freeform
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2017-11-01. Score: 1 | Accepted answer
  
  I've contacted Freeforms (Solspace). Unfortunately there is no solution for this problem (yet). Solspace told me:
  
  > This functionality currently isn't possible with Freeform. It's something on our feature requests list though.
  
  
  ---
  
  ### Answer by username_1 on 2017-10-25. Score: 0
  
  Never used Freeform before, but it looks like that [event](https://solspace.com/craft/freeform/docs/events-and-hooks/#event-onbeforesave-form) has a `model` param passed into it.
  
  You should be able to add errors to it like any other models in Craft.
  
  ```
  craft()->on(
      "freeform_submissions.onBeforeSave",
      function (Event $event) {
  
          // Let Freeform know the form is not valid
          $event->performAction = false;
  
          $event->params['model']->addError('email', 'This email is already in use!');
      }
  );
  
  ```
  
  This assumes that there is an 'email' attribute on the `Freeform_SubmissionModel` class and there is logic to display errors in your template similar to: <https://craftcms.com/docs/templating/entry-form>
  
  > **Comments:**
  > **username_0**: Unfortunately this won't work.  
  
  ---
  
  