CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Profiles (Moderator: Dave Greenberg) »
  • Alter Advance Filter for Contact Reference Custom Field Dynamically
Pages: [1]

Author Topic: Alter Advance Filter for Contact Reference Custom Field Dynamically  (Read 1234 times)

jackrabbithanna

  • I post occasionally
  • **
  • Posts: 61
  • Karma: 3
  • Quick like bunny
    • http://www.skvare.com
  • CiviCRM version: 4.3.5
  • CMS version: Drupal 7.23
  • MySQL version: 5.1
  • PHP version: 5.3.3
Alter Advance Filter for Contact Reference Custom Field Dynamically
July 11, 2013, 12:00:38 pm
I am trying to create a set of conditional contact reference fields.  I have two organization contact subtypes, lets call them District and Campus.  I've also created a relationship type District of/Campus of to be able to relate campuses to districts.  Using the advanced filter feature for contact reference fields, I can limit the contacts that are available to be found by the autocomplete widget.  So I can limit the District field to District contacts, and the Campus Field to Campus contacts.  Thats great.

What would be nice is to be able to alter the advanced filter for the campus field so that when some one selects a District, the Campus choices are limited to those which have a relationship with selected District.


Is there a way to dynamically alter the Advanced Filter for a contact reference field, I assume by some javascript?

Thanks

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Alter Advance Filter for Contact Reference Custom Field Dynamically
July 11, 2013, 12:46:26 pm
I would remove the existing autocomplete js call and replace it by a call to the ajax api get, with the right params to filter

That's what I did on the faster autocomplete to remove the default one:
https://github.com/TechToThePeople/eu.tttp.qlookup

(in this case, I created a new api, but in your case using the existing contact.get should work)

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

jackrabbithanna

  • I post occasionally
  • **
  • Posts: 61
  • Karma: 3
  • Quick like bunny
    • http://www.skvare.com
  • CiviCRM version: 4.3.5
  • CMS version: Drupal 7.23
  • MySQL version: 5.1
  • PHP version: 5.3.3
Re: Alter Advance Filter for Contact Reference Custom Field Dynamically
July 11, 2013, 08:30:26 pm
Quote
I would remove the existing autocomplete js call and replace it by a call to the ajax api get, with the right params to filter

Ok, I'm looking through your qlookup extension code, but I'm not quite sure where the existing auotcomplete js call is removed.  Do you mean, remove it from a template file, or is this done with php code?

My reach may exceed my grasp, but this would be an elegant solution to the problem.  Mind giving me a lil more hand-holding?

Thanks

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Alter Advance Filter for Contact Reference Custom Field Dynamically
July 11, 2013, 10:30:45 pm
I changed the id of the field so the default autocomplete (that is binding to this id) wouldn't find it.

Code: [Select]
$content = str_replace ("#sort_name_navigation","#disabled_by_qloockup"
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Profiles (Moderator: Dave Greenberg) »
  • Alter Advance Filter for Contact Reference Custom Field Dynamically

This forum was archived on 2017-11-26.