Answers.Body: <p>CiviCRM Entity you can reference contacts, like from nodes with the Entity Reference module...To get the UI you describe, should try the Dynamic dependent fields module, with its submodule DDF Entity Reference</p>
  
  <p><a href="https://www.drupal.org/project/ddf" rel="nofollow noreferrer">https://www.drupal.org/project/ddf</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-18T02:11:19.383Z
Answers.LastActivityDate: 2017-08-18T02:11:19.383Z
Answers.UserDisplayName: jackrabbithanna
Body: <p>Working on custom enhancement, two text fields Parent and Child field.</p>
  
  <p>Existing:-</p>
  
  <ol>
  <li>Parent autocomplete - lists all existing contacts </li>
  <li>Child autocomplete  - list all existing contacts</li>
  </ol>
  
  <p>Required:-</p>
  
  <ol>
  <li>Parent autocomplete - lists all existing contacts </li>
  <li>Child autocomplete  - Parent specific</li>
  </ol>
  
  <p>Using:- addEntityRef</p>
  
  <pre><code> $form-&gt;addEntityRef('parenttwo_id', ts('Parent Contact'), array(
                      'placeholder' =&gt; ts('- select or create contact -'),
                      'create' =&gt; 'Parent_profile',
                      'api' =&gt; array('params' =&gt; array('contact_type' =&gt; 'Individual')),
                    ), FALSE);
  
  
   $form-&gt;addEntityRef('parenttwo_id', ts('Child Contact'), array(
                      'placeholder' =&gt; ts('- select or create contact -'),
                      'create' =&gt; 'Child_profile',
                      'api' =&gt; array('params' =&gt; array('contact_type' =&gt; 'Individual')),
                    ), FALSE);
  </code></pre>
  
  <p>Can't do below method because contact id must be dynamic one,
  Means on searching of child contact field must lookup the relationship and fetch parent1's children.</p>
  
  <pre><code> 'api' =&gt; array('params' =&gt; array('contact_type' =&gt; 'Individual', 'contact_id' =&gt; '123123')
  </code></pre>
  
  <p>Can't do through simple textfield and ajax request because for contact creation profiles are being used.</p>
  
  <p>Any other method available which can be used for this case?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-08-08T13:26:23.287Z
Comments.Text: If you're on Drupal tools like webform_civicrm and civicrm_entity will let you do things like this (and more) practically out of the box.
Comments.UserDisplayName: KarinG - Semper IT
Tags: <api><relationships><forms>
Title: Dependant autocomplete civicrm
ThreadText: # Dependant autocomplete civicrm
  
  (Asked by: username_0 on 2017-08-08)
  
  Working on custom enhancement, two text fields Parent and Child field.
  
  Existing:-
  
  1. Parent autocomplete - lists all existing contacts
  2. Child autocomplete - list all existing contacts
  
  Required:-
  
  1. Parent autocomplete - lists all existing contacts
  2. Child autocomplete - Parent specific
  
  Using:- addEntityRef
  
  ```
   $form->addEntityRef('parenttwo_id', ts('Parent Contact'), array(
                      'placeholder' => ts('- select or create contact -'),
                      'create' => 'Parent_profile',
                      'api' => array('params' => array('contact_type' => 'Individual')),
                    ), FALSE);
  
   $form->addEntityRef('parenttwo_id', ts('Child Contact'), array(
                      'placeholder' => ts('- select or create contact -'),
                      'create' => 'Child_profile',
                      'api' => array('params' => array('contact_type' => 'Individual')),
                    ), FALSE);
  
  ```
  
  Can't do below method because contact id must be dynamic one,
  Means on searching of child contact field must lookup the relationship and fetch parent1's children.
  
  ```
   'api' => array('params' => array('contact_type' => 'Individual', 'contact_id' => '123123')
  
  ```
  
  Can't do through simple textfield and ajax request because for contact creation profiles are being used.
  
  Any other method available which can be used for this case?
  
  **Tags:** api, relationships, forms
  
  > **Comments:**
  > **username_1**: If you're on Drupal tools like webform_civicrm and civicrm_entity will let you do things like this (and more) practically out of the box.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2017-08-18. Score: 1
  
  CiviCRM Entity you can reference contacts, like from nodes with the Entity Reference module...To get the UI you describe, should try the Dynamic dependent fields module, with its submodule DDF Entity Reference
  
  <https://www.drupal.org/project/ddf>
  
  
  ---
  
  