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) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • New Event registration form - hook_civicrm_contactListQuery
Pages: [1]

Author Topic: New Event registration form - hook_civicrm_contactListQuery  (Read 1235 times)

Rajesh

  • I post occasionally
  • **
  • Posts: 78
  • Karma: 10
  • CiviCRM version: 4.2.x, 4.3.x, 4.4.x
  • CMS version: Drupal 7.xx, Wordpress 3.5.x - 3.6.x, Joomla 3.1
  • MySQL version: 5.5.20
  • PHP version: 5.3.10
New Event registration form - hook_civicrm_contactListQuery
December 07, 2010, 01:32:19 am
Hello everyone,

Dont know where to post this topic. Posting it here as im using hooks in the new event registration form.

Here is the scenario.

I have created 2 custom fields (data type - Contact Reference , field type - Autocomplete-Select) for a specific event type and the custom fields are 'Organisation name' (which is hosting the event) and 'Event Admin' (admin of the event).

In the event registration form, im using hook_civicrm_contactListQuery to restrict contact type 'Organisation' in 'Organisation name' field and 'Individual' in 'Event Admin' field.

But what i want is, after selecting the organisation in 'Organisation name' field, i want only the 'Individual' related to the selected organisation to be listed in 'Event Admin' field.

Has anyone done this before? I would appreciate any advice.

Thanks in advance.

- Rajesh

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: New Event registration form - hook_civicrm_contactListQuery
December 07, 2010, 07:31:18 am
Hi,

IMO, that's one of the scenari where using jquery and modify the ajax calls works better.

http://civicrm.org/blogs/xavier/how-customise-contact-reference-custom-field

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

Rajesh

  • I post occasionally
  • **
  • Posts: 78
  • Karma: 10
  • CiviCRM version: 4.2.x, 4.3.x, 4.4.x
  • CMS version: Drupal 7.xx, Wordpress 3.5.x - 3.6.x, Joomla 3.1
  • MySQL version: 5.5.20
  • PHP version: 5.3.10
Re: New Event registration form - hook_civicrm_contactListQuery
December 21, 2010, 07:28:21 am
Hi Xavier

I tried modifying the ajay call and it doesnt work for me. I dont know where im doing it wrong. I am posting the code here, if in case you can point me in the right direction.

Code: [Select]
cj(document).ready(function() {
        var ajaxCallUrl = "/index.php?q=civicrm/ajax/rest&json=1&fnName=civicrm/relationship/get&contact_id=2&contact_type=Individual";
        cj( "#custom_3_-1" ).autocomplete( ajaxCallUrl, {
             dataType:"json",
             formatItem: function(data,i,max,value,term){ return value;},
             parse: function(data){
                 var acd = new Array();
                 for(id in data){
                   acd.push({ data:data[id], value:data[id].display_name, result:data[id].display_name });
                 }
                 return acd;
             },
               width: 500,
               delay:50,
               max:200,
               mustMatch: true,
               autoFill:true,
               selectFirst: true

        });    

});

Thanks

- Rajesh
« Last Edit: December 21, 2010, 07:32:17 am by rajesh »

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • New Event registration form - hook_civicrm_contactListQuery

This forum was archived on 2017-11-26.