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) »
  • How to get custom Field value on submit?
Pages: [1]

Author Topic: How to get custom Field value on submit?  (Read 640 times)

Siv

  • I post occasionally
  • **
  • Posts: 94
  • Karma: -17
  • CiviCRM version: 4.6.2
  • CMS version: Drupal 7.44
  • MySQL version: 5.5.24
  • PHP version: 5.3.13
How to get custom Field value on submit?
August 17, 2011, 02:09:40 am
I have created a new Custom Group with style of Tab and it will allow multiple values to capture.there are two fileds in this group the value of second will change based on First select box value using ajax call and i have written formRule for validation.when i submit if there is any error the second dropdown  value get empty.so i have get the first dropdown value and fill the second one on submit. how to get The selected value of First DropDown?

bpmccain

  • I post frequently
  • ***
  • Posts: 255
  • Karma: 5
  • CiviCRM version: 4.1
  • CMS version: Drupal 7.12
  • MySQL version: 5.2
  • PHP version: 5.2
Re: How to get custom Field value on submit?
August 17, 2011, 05:27:24 am
If I am understanding correctly, when your form is saved, you want to get the value of one custom field and programmatically set the value of the second custom field.

Sounds like a case for a civicrm_custom hook.
http://wiki.civicrm.org/confluence/display/CRMDOC40/CiviCRM+hook+specification#CiviCRMhookspecification-hookcivicrmcustom

That will be called automatically after a change has been made to a custom field.

Some background reading on hooks here:
http://en.flossmanuals.net/civicrm/ch067_hooks/

sussdorff

  • I post occasionally
  • **
  • Posts: 36
  • Karma: 4
  • CiviCRM version: 3.4
  • CMS version: Drupal 6
Re: How to get custom Field value on submit?
August 17, 2011, 08:53:23 am
Hmm... Why don't you make the second select box mandatory as well? This way, if the selecting of the first drop down box fails in setting the second box correctly, an error is provided.

Not sure enough if you want to achieve that, otherwise a _post hook can do the trick of saving the correct value / pass the correct value for the second drop down to the next form.

There are lot's of code examples on how to use the hooks and I can highly recommend reading some, this helps a lot in understanding how to amend CiviCRM without ever touching the core.

bpmccain

  • I post frequently
  • ***
  • Posts: 255
  • Karma: 5
  • CiviCRM version: 4.1
  • CMS version: Drupal 7.12
  • MySQL version: 5.2
  • PHP version: 5.2
Re: How to get custom Field value on submit?
August 17, 2011, 09:08:18 am
Just an FYI, a _post hook won't be triggered on changes to a custom field, only to a core field.

If you want it triggered on a custom field change, you have to use a _custom hook

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • How to get custom Field value on submit?

This forum was archived on 2017-11-26.