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 Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Help with custom data in New Individual page
Pages: [1]

Author Topic: Help with custom data in New Individual page  (Read 1312 times)

leapywca

  • Guest
Help with custom data in New Individual page
October 28, 2009, 02:46:14 pm
hi
I'm trying to create a custom field in the New Individual page. I wanted to make a radio button yes or no type. I was trying to make it so that when No option is selected another custom field would pop out. This functionality is similiar to the "is deceased" option in the demographics tab of New Individual page. However I'm not able to apply the onClick call back functionality for my custom field like the one for "is deceased" check box. I have to refresh the page after selecting "no" to see the new custom field. So my question is how would I be able have a onClick call back functionality? Any help regarding this would be really appreciated. Thanks!

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Help with custom data in New Individual page
October 28, 2009, 04:27:48 pm

1. i'd expose both the radio button and the other custom field

2. on page load or if the option is yes, hide the box

3. on the onclick event for the radio button No, show the custom field box

You should be able to do steps 2 and 3 via jQuery

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

leapywca

  • Guest
Re: Help with custom data in New Individual page
October 29, 2009, 06:18:20 am
Thanks for your reply Donald. Where do you think in the code(in which file) can I set the onclick event for custom fields? I created the javascript function in CustomData.tpl for showing the field depending on radio button select but I dont get it where in the code I can associate it with onclick event. 

In the CiviCRM default field demographics it is done by calling  $form->addElement('checkbox', 'is_deceased', null, ts('Contact is deceased'), array('onclick' =>"showDeceasedDate()"));  However I am unable to find where this could be accomplished for custom data fields.
« Last Edit: October 29, 2009, 07:27:14 am by leapywca »

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Help with custom data in New Individual page
October 29, 2009, 10:14:12 am

Use jQuery's event handling mechanism.

check an article like: http://www.siphilp.co.uk/archive/2009/04/13/jquery-fun-with-radio-button-lists-checkboxes-and-labels.aspx

u dont need to modify the input element html :)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Help with custom data in New Individual page

This forum was archived on 2017-11-26.