Body: <p>Using this code</p>
  
  <p>if ($fields["custom_111_79"] == 0) $errors["custom_111_79"] = "Please enter number of physio sessions";</p>
  
  <p>The evaluation is done correctly, but the error message does not appear against the custom field, but instead as a general error message top right of the screen.</p>
  
  <p>This is in civi_case.</p>
  
  <p>Is this supposed to work?
  Is there another way of making custom fields work like normal fields?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-26T16:39:11.690Z
Comments.Text: The "79" is going to change for different records, and on a new form will be "-1". Also try it with just custom_111 when you set $errors.
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-27T08:14:51.390Z
Comments.Text: Yes, aware of the changing suffix, and removing it makes no difference.
Comments.UserDisplayName: Simon Walden
Tags: <hooks><validation><errorhandling>
Title: Errors not showing against custom fields using hook validateForm()
ThreadText: # Errors not showing against custom fields using hook validateForm()
  
  (Asked by: username_0 on 2019-11-26)
  
  Using this code
  
  if ($fields["custom\_111\_79"] == 0) $errors["custom\_111\_79"] = "Please enter number of physio sessions";
  
  The evaluation is done correctly, but the error message does not appear against the custom field, but instead as a general error message top right of the screen.
  
  This is in civi\_case.
  
  Is this supposed to work?
  Is there another way of making custom fields work like normal fields?
  
  **Tags:** hooks, validation, errorhandling
  
  > **Comments:**
  > **username_1**: The "79" is going to change for different records, and on a new form will be "-1". Also try it with just custom_111 when you set $errors.  
  > **username_0**: Yes, aware of the changing suffix, and removing it makes no difference.  
  
  ---
  
  ## 0 answers
  
  