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) »
  • aborting save operation
Pages: [1]

Author Topic: aborting save operation  (Read 1622 times)

taram

  • I post occasionally
  • **
  • Posts: 35
  • Karma: 2
aborting save operation
November 12, 2009, 02:53:28 pm
When the status of an activity is changed, I need to allow the status change to go through only if certain conditions are met. If not, the status should remain the same. I was looking at the pre hook but saw this note in the pre hook documentation 'This hook does not allow the abort of the operation, use a form hook instead.' I looked for more information on this but couldn't find any. Has anyone done this kind of a thing before?
I appreciate your help.
-Tara.

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: aborting save operation
November 12, 2009, 04:25:43 pm

use

hook_civicrm_validate

http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+hook+specification

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

taram

  • I post occasionally
  • **
  • Posts: 35
  • Karma: 2
Re: aborting save operation
November 17, 2009, 02:58:21 pm
Thanks Lobo.
I am looking at using civicrm_validate but activityid & activitytypeid are protected. When I try $form->get('_activityId') or even $form->get('_name') I am not getting any value even though I can see all the values in the debugger. How can I validate without having access to the key fields?

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: aborting save operation
November 17, 2009, 04:14:48 pm

you should use

$form->getVar( '_activityId' );
$form->setVar( '_activityId', $value );

make sure u spell the name of the variable right

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

taram

  • I post occasionally
  • **
  • Posts: 35
  • Karma: 2
Re: aborting save operation
November 17, 2009, 08:56:49 pm
I get 'Call to undefined function getVar() ' & I do not see this function in Form.php. We are using civi 2.0.6 & this is the implementation for get():
    function get( $name ) {
        return $this->controller->get( $name );
    }

Is there a workaround?
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: aborting save operation
November 17, 2009, 09:28:40 pm

that function is defined in 2.1 or later? you might want to backport it from the latest release. its a pretty simple function

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

taram

  • I post occasionally
  • **
  • Posts: 35
  • Karma: 2
Re: aborting save operation
November 18, 2009, 10:32:48 am
I backported getVar & now can access all the data.
Thank you for your help.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • aborting save operation

This forum was archived on 2017-11-26.