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) »
  • hook questions
Pages: [1]

Author Topic: hook questions  (Read 561 times)

jcm55

  • I post occasionally
  • **
  • Posts: 96
  • Karma: 14
hook questions
September 27, 2012, 04:06:07 pm
I'm working on a project described here:

http://forum.civicrm.org/index.php/topic,18837.msg78256.html#msg78256

Essentially it's a drupal module that implements buildForm(), validate() and postProcess() hooks that include classes/functions from another (non-drupal / non-CMS) PHP program.

A few hook questions have come up while I'm working:

1) If my validate() hook returns errors, does the custom buildForm() hook get called again when rebuilding the form with the errored fields highlighted?

2) Is there an easy way to get a participant count from a submitted price set?  I want to check the partipant count against some other fields in my validate().

3) What's the right way to handle an error that arises in my custom postProcess()?  postProcess() return val isn't checked it looks like.

I'm sure there will be more...

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: hook questions
September 27, 2012, 09:48:29 pm

1. no, the form is rendered with the errors in line

2. dont know, but i would check the participant and/or price set BAO classes

3. in general we try to catch all these errors in validate. depending on the error we typically redirect to a different page (so contribution pages redirect to the main page etc)

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

jcm55

  • I post occasionally
  • **
  • Posts: 96
  • Karma: 14
Re: hook questions
September 27, 2012, 10:26:53 pm
Thanks Lobo.

Another question -- is it possible to have a module include an .extra.tpl ?

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: hook questions
September 27, 2012, 10:43:46 pm

yes. the module can add to the template path in smarty and use its own template directory to add the .extra.tpl file

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) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • hook questions

This forum was archived on 2017-11-26.