Answers.Body: <p>The best way to handle this is with an extension that calls <code>hook_civicrm_validateForm</code>.  Documentation is available here: <a href="http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_validateForm" rel="nofollow">http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_validateForm</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-22T17:42:03.420Z
Answers.LastActivityDate: 2015-08-22T17:42:03.420Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Body: <p>When creating a new Activity record, I need to require the "With contact" and "Assigned to" fields have a contact selected.</p>
  
  <p>In the activity/form/activity.php file I can add 'required'=>TRUE to the various arrays, but that setting only works for the fields without a selector (e.g. subject, location, duration).  </p>
  
  <p>This can certainly be done with javascript in an extra.tpl file (and might be preferable, as it can be conditional to the activity type), but is there a way to modify either the template or php files to require a selected contact?</p>
  
Tags: <custom-templates><javascript><activity>
Title: Requiring "Assigned" and "Target" contacts when recording Activity
ThreadText: # Requiring "Assigned" and "Target" contacts when recording Activity
  
  (Asked by: username_0 on 2015-07-08)
  
  When creating a new Activity record, I need to require the "With contact" and "Assigned to" fields have a contact selected.
  
  In the activity/form/activity.php file I can add 'required'=>TRUE to the various arrays, but that setting only works for the fields without a selector (e.g. subject, location, duration).
  
  This can certainly be done with javascript in an extra.tpl file (and might be preferable, as it can be conditional to the activity type), but is there a way to modify either the template or php files to require a selected contact?
  
  **Tags:** custom-templates, javascript, activity
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-08-22. Score: 1
  
  The best way to handle this is with an extension that calls `hook_civicrm_validateForm`. Documentation is available here: <http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_validateForm>
  
  
  ---
  
  