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) »
  • validate hook possibly broken?
Pages: [1]

Author Topic: validate hook possibly broken?  (Read 1007 times)

lcdweb

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1620
  • Karma: 116
    • www.lcdservices.biz
  • CiviCRM version: many versions...
  • CMS version: Joomla/Drupal
  • MySQL version: 5.1+
  • PHP version: 5.2+
validate hook possibly broken?
December 26, 2011, 07:45:28 am
i'm using the validate hook on CRM_Contact_Form_Relationship and it doesn't appear to be working --
when I construct and return the errors array, it still validates.
as a workaround, I can set an error with the form object: $form->setElementError('field', 'message');

but the documented usage appears to be broken -- at least on this form.
support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

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: validate hook possibly broken?
December 26, 2011, 05:58:50 pm

I tried this and it worked (on v3.4)

Code: [Select]
function civicrm_civicrm_validate( $formName, &$fields, &$files, &$form ) {
    if ( $formName == 'CRM_Contact_Form_Relationship' &&
         CRM_Utils_Array::value( '_qf_Relationship_refresh', $fields ) !== 'Search' ) {
        $errors = array( 'relationship_type_id' => 'You will never get past this');
        return $errors;
    }
}

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

lcdweb

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1620
  • Karma: 116
    • www.lcdservices.biz
  • CiviCRM version: many versions...
  • CMS version: Joomla/Drupal
  • MySQL version: 5.1+
  • PHP version: 5.2+
Re: validate hook possibly broken?
December 26, 2011, 06:21:58 pm
i dropped the same exact code into 4.0.8 and it didn't work.
i can echo inside the condition and confirm that it's getting there. but returning the errors array doesn't do anything.
support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

lcdweb

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1620
  • Karma: 116
    • www.lcdservices.biz
  • CiviCRM version: many versions...
  • CMS version: Joomla/Drupal
  • MySQL version: 5.1+
  • PHP version: 5.2+
Re: validate hook possibly broken?
December 26, 2011, 08:22:36 pm
Lobo -- did more testing and the bug seems to be limited to J16+/C4
I tested on D7+trunk, J15+C3.4 and J16+C4, and it worked on all but the J16+C4
very strange. maybe there's a name conflict or something?
support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

lcdweb

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1620
  • Karma: 116
    • www.lcdservices.biz
  • CiviCRM version: many versions...
  • CMS version: Joomla/Drupal
  • MySQL version: 5.1+
  • PHP version: 5.2+
Re: validate hook possibly broken?
December 26, 2011, 08:52:25 pm
confirmed with Lobo that it is a bug.
issue filed here: http://issues.civicrm.org/jira/browse/CRM-9395
support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • validate hook possibly broken?

This forum was archived on 2017-11-26.