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 (Moderator: Dave Greenberg) »
  • Passing Variables to Forms
Pages: [1]

Author Topic: Passing Variables to Forms  (Read 765 times)

bizzynate

  • I’m new here
  • *
  • Posts: 9
  • Karma: 0
Passing Variables to Forms
December 21, 2010, 08:40:36 am
I'm curious to know if anyone has tried passing $_GET and $_POST variables to a form with any success?

Specifically, I'm thinking about ways to streamline the user experience by passing information he/she has previously entered. The following illustrates a scenario:
  • The user comes to my website. On the sidebar, is a module for making a contribution, into which he/she can enter a value.
  • The user clicks "continue" and the variable is passed to an existing CiviContribute contribution page
  • Once the user lands on the contribution page, the "amount" field has changed based on the passed variable. Ideally, this would only display the amount as a hidden variable and HTML text, since the user has already indicated his/her preference and having it appear in form elements would be redundant.

This could (and should) be a global option, whereby any form can accept an incoming value simply by passing the variable with the same name. I've seen this behavior in other similar CRM systems with user-facing forms and besides its helpfulness, it's also certainly an indicator of a solid design.

Does this exist for CiviCRM? If so, how does one use it? If not, can it be hooked somehow, and has anyone tried it?
« Last Edit: December 21, 2010, 08:43:26 am by bizzynate »

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: Passing Variables to Forms
December 21, 2010, 06:04:04 pm

You can do the below by implementing hook_civicrm_buildForm. More details here:

http://wiki.civicrm.org/confluence/display/CRMDOC32/CiviCRM+hook+specification#CiviCRMhookspecification-hookcivicrmbuildForm

you can potentially generalize it and create a module that does exactly what you suggest. If you do so, please share your code so others can benefit

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 (Moderator: Dave Greenberg) »
  • Passing Variables to Forms

This forum was archived on 2017-11-26.