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 (Moderator: Donald Lobo) »
  • linked elements, how to?
Pages: [1]

Author Topic: linked elements, how to?  (Read 987 times)

Masked Marauder

  • I post occasionally
  • **
  • Posts: 30
  • Karma: 1
  • \__^..^
  • CiviCRM version: 4.5.5
  • CMS version: drupal-6.34
  • MySQL version: 5.5.40-36
  • PHP version: 5.4.34
linked elements, how to?
February 22, 2010, 02:07:25 pm
I haven't seen this problem/situation covered here yet.

How can/should I link input fields where options are contingent on a prior choice?

For example, in a game tournament event an applicant can come in as unaffiliated, in which case the user is assigned to a team by the organizers off-line, or as already a member, in which case a text widget is presented for the user to enter the team name.

Is this available or does it need to be cooked up ad hoc?  I think I can envision how to do it with hooks, but am not sure how that would be set up on the event registration form configurator.  Do I set up all the fields in the event form and then manage contingent linkages with hook jiggery-pokery behind the scenes, or is there a better way? 

I'd love to see a snippet if there's something close to this somewhere.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: linked elements, how to?
February 22, 2010, 02:15:37 pm
I'd cheat and do that on the client side only:

get all the fields in the html, and add a bit of jquery love to hide/show the right field based on the value of a specific field (on the blur event)

In a profile, all the inputs have an id, so it's usually easy to add the display logic you want.

Good luck

X+

P.S. you can add a custom template per profile, so your custom jquery code won't polute other profiles.
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

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: linked elements, how to?
February 22, 2010, 02:21:10 pm

if you do this, please publish your snippet so other folks can benefit and make use of your work :)

we use the chainedSelect jquery code for the state/country widget and it works quite nicely :)

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

Masked Marauder

  • I post occasionally
  • **
  • Posts: 30
  • Karma: 1
  • \__^..^
  • CiviCRM version: 4.5.5
  • CMS version: drupal-6.34
  • MySQL version: 5.5.40-36
  • PHP version: 5.4.34
Re: linked elements, how to?
February 23, 2010, 10:41:57 am
OK, thanks for the suggestion.  I'll try to track it down.

In general, how stable are the for element IDs across forms?  If I use price set X in evemt Y and its id is 'qf_10f052', will it be 'qf_10f052' if I use the same price set in event Z, or will it vary from event to event?

I'm wondering how general the solution should be.


Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • linked elements, how to?

This forum was archived on 2017-11-26.