Answers.Body: <p>You might have already checked <a href="https://civicrm.stackexchange.com/questions/3382/field-like-current-employer-that-creates-new-organization-and-relationship?rq=1">field like &quot;Current Employer&quot; that creates new organization and relationship</a>. Post hook is the most straight-forward and correct way to proceed here. </p>
  
  <p>You could give a common prefix kind of name to your custom field and write your code in such a way that it performs the action only when custom field has that prefix in the title/name. This way, you won't need to modify the extension every time a new custom field is added.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-15T04:55:21.310Z
Answers.LastActivityDate: 2018-10-15T04:55:21.310Z
Answers.UserDisplayName: jitendra - fuzion
Answers.Body: <p>@jitendra's answer is how we will likely proceed to some extent however we will likely integrate it with something like
  <a href="https://github.com/eileenmcnaughton/org.wikimedia.relationshipblock" rel="nofollow noreferrer">Relationship block</a> which seems to do a lot of what are users want. </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-31T23:20:03.473Z
Answers.LastActivityDate: 2018-10-31T23:20:03.473Z
Answers.UserDisplayName: tanbog
Body: <p>I have been asked to add some custom fields to the default CiviCRM Interface that bahave like the current employer field. </p>
  
  <p>That is to say, my users want to create certain relationships and have them turn up in the relationships tab. </p>
  
  <p>I had originally implemented this as a contact reference with a filter to look up the specific sub-set of contacts needed but I have been asked to make them relationships.  </p>
  
  <p>I realise I can implement this using webforms integration (we are using Drupal 7) but I have been specifically asked to implement this on the default UI.</p>
  
  <p>I have also read it can be achieved using <a href="https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_post/" rel="nofollow noreferrer">hook_civicrm_post</a> however, I was hoping there was a more straightforward way that I was overlooking so that if in the future one of my users needs to add a new relationship custom field they don't need to update code in an extension</p>
  
Tags: <custom-fields><relationships>
Title: Current Employer style field for a custom field
ThreadText: # Current Employer style field for a custom field
  
  (Asked by: username_0 on 2018-10-12)
  
  I have been asked to add some custom fields to the default CiviCRM Interface that bahave like the current employer field.
  
  That is to say, my users want to create certain relationships and have them turn up in the relationships tab.
  
  I had originally implemented this as a contact reference with a filter to look up the specific sub-set of contacts needed but I have been asked to make them relationships.
  
  I realise I can implement this using webforms integration (we are using Drupal 7) but I have been specifically asked to implement this on the default UI.
  
  I have also read it can be achieved using [hook\_civicrm\_post](https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_post/) however, I was hoping there was a more straightforward way that I was overlooking so that if in the future one of my users needs to add a new relationship custom field they don't need to update code in an extension
  
  **Tags:** custom-fields, relationships
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2018-10-15. Score: 2 | Accepted answer
  
  You might have already checked [field like "Current Employer" that creates new organization and relationship](https://civicrm.stackexchange.com/questions/3382/field-like-current-employer-that-creates-new-organization-and-relationship?rq=1). Post hook is the most straight-forward and correct way to proceed here.
  
  You could give a common prefix kind of name to your custom field and write your code in such a way that it performs the action only when custom field has that prefix in the title/name. This way, you won't need to modify the extension every time a new custom field is added.
  
  
  ---
  
  ### Answer by username_0 on 2018-10-31. Score: 1
  
  @username_1's answer is how we will likely proceed to some extent however we will likely integrate it with something like
  [Relationship block](https://github.com/eileenmcnaughton/org.wikimedia.relationshipblock) which seems to do a lot of what are users want.
  
  
  ---
  
  