1

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?

  • 2
    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. – KarinG - Semper IT Aug 8 '17 at 13:26
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.