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) »
  • ID field lacking in hook_civicrm_postProcess
Pages: [1]

Author Topic: ID field lacking in hook_civicrm_postProcess  (Read 729 times)

jstn

  • I’m new here
  • *
  • Posts: 10
  • Karma: 0
  • CiviCRM version: 4.0.0
  • CMS version: Drupal 7 Stable
  • MySQL version: Recent Stable?
  • PHP version: PHP 5
ID field lacking in hook_civicrm_postProcess
January 10, 2012, 08:37:11 am
I couldn't find an id field anywhere in the $form object. (I see a similar issue here: http://issues.civicrm.org/jira/browse/CRM-7892.)

I'm trying to use this hook after a search is saved (CRM_Contact_Form_Task_SaveSearch).

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: ID field lacking in hook_civicrm_postProcess
January 10, 2012, 09:40:19 am

I checked that file: CRM/Contact/Form/Task/SaveSearch.php

and there is a protected $_id in that file

so not sure what u mean?

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

jstn

  • I’m new here
  • *
  • Posts: 10
  • Karma: 0
  • CiviCRM version: 4.0.0
  • CMS version: Drupal 7 Stable
  • MySQL version: Recent Stable?
  • PHP version: PHP 5
Re: ID field lacking in hook_civicrm_postProcess
January 10, 2012, 10:32:28 am
In the hook, when that particular form is submitted, I executed drupal_set_message(serialize($form)). I knew the id and the ssID of this new group. However, I couldn't find these numbers anywhere in the output. (I just did again and that field is NULL.)

I'm off for now I won't be able to respond until later so here is the output if you want to look through it.

Code: [Select]
O:32:"CRM_Contact_Form_Task_SaveSearch":39:{s:6:"*_id";N;s:8:"*_task";s:2:"13";s:11:"_contactIds";N;s:13:"_contactTypes";N;s:19:"*_componentClause";N;s:18:"*_componentTable";N;s:16:"*_componentIds";N;s:9:"*_state";N;s:8:"*_name";s:10:"SaveSearch";s:9:"*_title";N;s:11:"*_options";N;s:10:"*_action";i:512;s:12:"*_renderer";N;s:8:"_actions";a:0:{}s:10:"controller";O:29:"CRM_Contact_Controller_Search":14:{s:9:"*_title";s:15:"Advanced Search";s:4:"_key";s:37:"10e67cbc50a3daa72775ed52269c94ab_2249";s:9:"*_scope";s:67:"CRM_Contact_Controller_Search_10e67cbc50a3daa72775ed52269c94ab_2249";s:16:"*_stateMachine";O:31:"CRM_Contact_StateMachine_Search":7:{s:8:"*_task";s:32:"CRM_Contact_Form_Task_SaveSearch";s:14:"*_controller";r:16;s:10:"*_states";a:3:{s:8:"Advanced";O:14:"CRM_Core_State":5:{s:8:"*_name";s:8:"Advanced";s:8:"*_type";i:1;s:8:"*_back";N;s:8:"*_next";s:10:"SaveSearch";s:16:"*_stateMachine";r:20;}s:10:"SaveSearch";O:14:"CRM_Core_State":5:{s:8:"*_name";s:10:"SaveSearch";s:8:"*_type";i:4;s:8:"*_back";s:8:"Advanced";s:8:"*_next";s:6:"Result";s:16:"*_stateMachine";r:20;}s:6:"Result";O:14:"CRM_Core_State":5:{s:8:"*_name";s:6:"Result";s:8:"*_type";i:2;s:8:"*_back";s:10:"SaveSearch";s:8:"*_next";N;s:16:"*_stateMachine";r:20;}}s:9:"*_pages";a:3:{s:32:"CRM_Contact_Form_Search_Advanced";N;s:32:"CRM_Contact_Form_Task_SaveSearch";N;s:28:"CRM_Contact_Form_Task_Result";N;}s:13:"*_pageNames";a:3:{i:0;s:8:"Advanced";i:1;s:10:"SaveSearch";i:2;s:6:"Result";}s:10:"*_action";s:3:"512";s:8:"*_name";N;}s:12:"*_embedded";b:0;s:19:"*_skipRedirection";b:0;s:6:"_print";i:0;s:10:"*_parent";N;s:12:"_destination";N;s:6:"_pages";a:3:{s:8:"Advanced";O:32:"CRM_Contact_Form_Search_Advanced":58:{s:11:"*_context";N;s:15:"*_contextMenu";N;s:8:"_groupID";N;s:10:"*_amtgID";N;s:8:"*_ssID";N;s:9:"*_force";N;s:20:"*_searchButtonName";N;s:19:"*_printButtonName";N;s:20:"*_actionButtonName";N;s:6:"_group";N;s:13:"_groupElement";N;s:14:"_groupIterator";N;s:4:"_tag";N;s:11:"_tagElement";N;s:11:"_formValues";N;s:10:"*_params";N;s:20:"*_returnProperties";N;s:19:"*_sortByCharacter";N;s:13:"*_ufGroupID";N;s:17:"*_componentMode";N;s:12:"*_operator";N;s:13:"*_modeValue";N;s:8:"*_done";N;s:16:"*_selectorName";s:20:"CRM_Contact_Selector";s:18:"*_customSearchID";N;s:21:"*_customSearchClass";N;s:9:"*_state";N;s:8:"*_name";s:8:"Advanced";s:9:"*_title";N;s:11:"*_options";N;s:10:"*_action";i:512;s:12:"*_renderer";N;s:8:"_actions";a:0:{}s:10:"controller";r:16;s:10:"_formBuilt";b:0;s:9:"_elements";a:0:{}s:13:"_elementIndex";a:0:{}s:15:"_duplicateIndex";a:0:{}s:9:"_required";a:0:{}s:9:"_jsPrefix";s:28:"Invalid information entered.";s:10:"_jsPostfix";s:28:"Please correct these fields.";s:11:"_datasource";N;s:14:"_defaultValues";a:0:{}s:15:"_constantValues";a:0:{}s:13:"_submitValues";a:5:{s:5:"qfKey";s:37:"10e67cbc50a3daa72775ed52269c94ab_2249";s:11:"_qf_default";s:15:"SaveSearch:next";s:5:"title";s:11:"Staff Again";s:11:"description";s:0:"";s:19:"_qf_SaveSearch_next";s:16:"Save Smart Group";}s:12:"_submitFiles";a:0:{}s:12:"_maxFileSize";i:209715200;s:10:"_freezeAll";b:0;s:6:"_rules";a:0:{}s:10:"_formRules";a:0:{}s:7:"_errors";a:0:{}s:13:"_requiredNote";s:111:"* denotes required field";s:14:"_flagSubmitted";b:1;s:11:"_attributes";a:4:{s:6:"action";s:32:"/civicrm/contact/search/advanced";s:6:"method";s:4:"post";s:4:"name";s:8:"Advanced";s:2:"id";s:8:"Advanced";}s:10:"_tabOffset";i:0;s:4:"_tab";s:1:" ";s:8:"_lineEnd";s:1:" ";s:8:"_comment";s:0:"";}s:10:"SaveSearch";r:1;s:6:"Result";O:28:"CRM_Contact_Form_Task_Result":38:{s:8:"*_task";N;s:11:"_contactIds";N;s:13:"_contactTypes";N;s:19:"*_componentClause";N;s:18:"*_componentTable";N;s:16:"*_componentIds";N;s:9:"*_state";N;s:8:"*_name";s:6:"Result";s:9:"*_title";N;s:11:"*_options";N;s:10:"*_action";i:512;s:12:"*_renderer";N;s:8:"_actions";a:0:{}s:10:"controller";r:16;s:10:"_formBuilt";b:0;s:9:"_elements";a:0:{}s:13:"_elementIndex";a:0:{}s:15:"_duplicateIndex";a:0:{}s:9:"_required";a:0:{}s:9:"_jsPrefix";s:28:"Invalid information entered.";s:10:"_jsPostfix";s:28:"Please correct these fields.";s:11:"_datasource";N;s:14:"_defaultValues";a:0:{}s:15:"_constantValues";a:0:{}s:13:"_submitValues";a:5:{s:5:"qfKey";s:37:"10e67cbc50a3daa72775ed52269c94ab_2249";s:11:"_qf_default";s:15:"SaveSearch:next";s:5:"title";s:11:"Staff Again";s:11:"description";s:0:"";s:19:"_qf_SaveSearch_next";s:16:"Save Smart Group";}s:12:"_submitFiles";a:0:{}s:12:"_maxFileSize";i:209715200;s:10:"_freezeAll";b:0;s:6:"_rules";a:0:{}s:10:"_formRules";a:0:{}s:7:"_errors";a:0:{}s:13:"_requiredNote";s:111:"* denotes required field";s:14:"_flagSubmitted";b:1;s:11:"_attributes";a:4:{s:6:"action";s:32:"/civicrm/contact/search/advanced";s:6:"method";s:4:"post";s:4:"name";s:6:"Result";s:2:"id";s:6:"Result";}s:10:"_tabOffset";i:0;s:4:"_tab";s:1:" ";s:8:"_lineEnd";s:1:" ";s:8:"_comment";s:0:"";}}s:8:"_actions";a:13:{s:8:"Advanced";O:28:"HTML_QuickForm_Action_Direct":0:{}s:10:"SaveSearch";O:28:"HTML_QuickForm_Action_Direct":0:{}s:6:"Result";O:28:"HTML_QuickForm_Action_Direct":0:{}s:7:"display";O:33:"CRM_Core_QuickForm_Action_Display":1:{s:16:"*_stateMachine";R:20;}s:4:"next";O:30:"CRM_Core_QuickForm_Action_Next":1:{s:16:"*_stateMachine";R:20;}s:4:"back";O:30:"CRM_Core_QuickForm_Action_Back":1:{s:16:"*_stateMachine";R:20;}s:7:"process";O:33:"CRM_Core_QuickForm_Action_Process":1:{s:16:"*_stateMachine";R:20;}s:6:"cancel";O:32:"CRM_Core_QuickForm_Action_Cancel":1:{s:16:"*_stateMachine";R:20;}s:7:"refresh";O:33:"CRM_Core_QuickForm_Action_Refresh":1:{s:16:"*_stateMachine";R:20;}s:4:"done";O:30:"CRM_Core_QuickForm_Action_Done":1:{s:16:"*_stateMachine";R:20;}s:4:"jump";O:30:"CRM_Core_QuickForm_Action_Jump":1:{s:16:"*_stateMachine";R:20;}s:6:"submit";O:32:"CRM_Core_QuickForm_Action_Submit":1:{s:16:"*_stateMachine";R:20;}s:6:"upload";O:32:"CRM_Core_QuickForm_Action_Upload":3:{s:15:"*_uploadNames";a:4:{i:0;s:12:"attachFile_1";i:1;s:12:"attachFile_2";i:2;s:12:"attachFile_3";i:3;s:10:"uploadFile";}s:13:"*_uploadDir";s:60:"/www/sites/durham/htdocs/sites/default/files/civicrm/upload/";s:16:"*_stateMachine";R:20;}}s:5:"_name";s:67:"CRM_Contact_Controller_Search_10e67cbc50a3daa72775ed52269c94ab_2249";s:6:"_modal";b:1;s:11:"_actionName";a:2:{i:0;s:10:"SaveSearch";i:1;s:4:"next";}}s:10:"_formBuilt";b:1;s:9:"_elements";a:6:{i:0;O:21:"HTML_QuickForm_hidden":9:{s:6:"_label";s:0:"";s:5:"_type";s:6:"hidden";s:11:"_flagFrozen";b:0;s:17:"_persistantFreeze";b:0;s:11:"_attributes";a:3:{s:4:"name";s:5:"qfKey";s:4:"type";s:6:"hidden";s:5:"value";s:37:"10e67cbc50a3daa72775ed52269c94ab_2249";}s:10:"_tabOffset";i:0;s:4:"_tab";s:1:" ";s:8:"_lineEnd";s:1:" ";s:8:"_comment";s:0:"";}i:1;O:19:"HTML_QuickForm_text":9:{s:6:"_label";s:4:"Name";s:5:"_type";s:4:"text";s:11:"_flagFrozen";b:0;s:17:"_persistantFreeze";b:1;s:11:"_attributes";a:5:{s:9:"maxlength";i:64;s:4:"size";i:30;s:4:"name";s:5:"title";s:4:"type";s:4:"text";s:5:"value";s:11:"Staff Again";}s:10:"_tabOffset";i:0;s:4:"_tab";s:1:" ";s:8:"_lineEnd";s:1:" ";s:8:"_comment";s:0:"";}i:2;O:23:"HTML_QuickForm_textarea":10:{s:6:"_value";s:0:"";s:6:"_label";s:11:"Description";s:5:"_type";s:8:"textarea";s:11:"_flagFrozen";b:0;s:17:"_persistantFreeze";b:1;s:11:"_attributes";a:3:{s:4:"rows";i:2;s:4:"cols";i:60;s:4:"name";s:11:"description";}s:10:"_tabOffset";i:0;s:4:"_tab";s:1:" ";s:8:"_lineEnd";s:1:" ";s:8:"_comment";s:0:"";}i:3;O:20:"HTML_QuickForm_group":14:{s:5:"_name";s:10:"group_type";s:9:"_elements";a:1:{i:0;O:23:"HTML_QuickForm_checkbox":10:{s:5:"_text";s:12:"Mailing List";s:6:"_label";s:0:"";s:5:"_type";s:8:"checkbox";s:11:"_flagFrozen";b:0;s:17:"_persistantFreeze";b:1;s:11:"_attributes";a:4:{s:2:"id";s:1:"2";s:4:"name";s:1:"2";s:4:"type";s:8:"checkbox";s:5:"value";i:1;}s:10:"_tabOffset";i:0;s:4:"_tab";s:1:" ";s:8:"_lineEnd";s:1:" ";s:8:"_comment";s:0:"";}}s:10:"_separator";s:18:"   ";s:9:"_required";a:0:{}s:11:"_appendName";b:1;s:6:"_label";s:10:"Group Type";s:5:"_type";s:5:"group";s:11:"_flagFrozen";b:0;s:17:"_persistantFreeze";b:0;s:11:"_attributes";N;s:10:"_tabOffset";i:0;s:4:"_tab";s:1:" ";s:8:"_lineEnd";s:1:" ";s:8:"_comment";s:0:"";}i:4;O:21:"HTML_QuickForm_hidden":9:{s:6:"_label";s:0:"";s:5:"_type";s:6:"hidden";s:11:"_flagFrozen";b:0;s:17:"_persistantFreeze";b:0;s:11:"_attributes";a:3:{s:4:"name";s:11:"_qf_default";s:4:"type";s:6:"hidden";s:5:"value";s:15:"SaveSearch:next";}s:10:"_tabOffset";i:0;s:4:"_tab";s:1:" ";s:8:"_lineEnd";s:1:" ";s:8:"_comment";s:0:"";}i:5;O:20:"HTML_QuickForm_group":14:{s:5:"_name";s:7:"buttons";s:9:"_elements";a:2:{i:0;O:21:"HTML_QuickForm_submit":9:{s:6:"_label";s:0:"";s:5:"_type";s:6:"submit";s:11:"_flagFrozen";b:0;s:17:"_persistantFreeze";b:0;s:11:"_attributes";a:4:{s:5:"class";s:19:"form-submit default";s:4:"name";s:19:"_qf_SaveSearch_next";s:5:"value";s:16:"Save Smart Group";s:4:"type";s:6:"submit";}s:10:"_tabOffset";i:0;s:4:"_tab";s:1:" ";s:8:"_lineEnd";s:1:" ";s:8:"_comment";s:0:"";}i:1;O:21:"HTML_QuickForm_submit":9:{s:6:"_label";s:0:"";s:5:"_type";s:6:"submit";s:11:"_flagFrozen";b:0;s:17:"_persistantFreeze";b:0;s:11:"_attributes";a:4:{s:5:"class";s:11:"form-submit";s:4:"name";s:19:"_qf_SaveSearch_back";s:5:"value";s:6:"Cancel";s:4:"type";s:6:"submit";}s:10:"_tabOffset";i:0;s:4:"_tab";s:1:" ";s:8:"_lineEnd";s:1:" ";s:8:"_comment";s:0:"";}}s:10:"_separator";a:2:{i:0;s:30:"     ";i:1;s:30:"     ";}s:9:"_required";a:0:{}s:11:"_appendName";b:0;s:6:"_label";s:0:"";s:5:"_type";s:5:"group";s:11:"_flagFrozen";b:0;s:17:"_persistantFreeze";b:0;s:11:"_attributes";N;s:10:"_tabOffset";i:0;s:4:"_tab";s:1:" ";s:8:"_lineEnd";s:1:" ";s:8:"_comment";s:0:"";}}s:13:"_elementIndex";a:6:{s:5:"qfKey";i:0;s:5:"title";i:1;s:11:"description";i:2;s:10:"group_type";i:3;s:11:"_qf_default";i:4;s:7:"buttons";i:5;}s:15:"_duplicateIndex";a:0:{}s:9:"_required";a:1:{i:0;s:5:"title";}s:9:"_jsPrefix";s:28:"Invalid information entered.";s:10:"_jsPostfix";s:28:"Please correct these fields.";s:11:"_datasource";N;s:14:"_defaultValues";a:0:{}s:15:"_constantValues";a:0:{}s:13:"_submitValues";a:5:{s:5:"qfKey";s:37:"10e67cbc50a3daa72775ed52269c94ab_2249";s:11:"_qf_default";s:15:"SaveSearch:next";s:5:"title";s:11:"Staff Again";s:11:"description";s:0:"";s:19:"_qf_SaveSearch_next";s:16:"Save Smart Group";}s:12:"_submitFiles";a:0:{}s:12:"_maxFileSize";i:209715200;s:10:"_freezeAll";b:0;s:6:"_rules";a:2:{s:5:"title";a:3:{i:0;a:6:{s:4:"type";s:9:"xssString";s:6:"format";N;s:7:"message";s:56:"Illegal characters in input (potential scripting attack)";s:10:"validation";s:6:"server";s:5:"reset";b:0;s:9:"dependent";N;}i:1;a:6:{s:4:"type";s:8:"required";s:6:"format";N;s:7:"message";s:25:"Name is a required field.";s:10:"validation";s:6:"server";s:5:"reset";b:0;s:9:"dependent";N;}i:2;a:6:{s:4:"type";s:12:"objectExists";s:6:"format";a:3:{i:0;s:21:"CRM_Contact_DAO_Group";i:1;N;i:2;s:5:"title";}s:7:"message";s:32:"Name already exists in Database.";s:10:"validation";s:6:"server";s:5:"reset";b:0;s:9:"dependent";N;}}s:11:"description";a:1:{i:0;a:6:{s:4:"type";s:9:"xssString";s:6:"format";N;s:7:"message";s:56:"Illegal characters in input (potential scripting attack)";s:10:"validation";s:6:"server";s:5:"reset";b:0;s:9:"dependent";N;}}}s:10:"_formRules";a:0:{}s:7:"_errors";a:0:{}s:13:"_requiredNote";s:111:"* denotes required field";s:14:"_flagSubmitted";b:1;s:11:"_attributes";a:4:{s:6:"action";s:32:"/civicrm/contact/search/advanced";s:6:"method";s:4:"post";s:4:"name";s:10:"SaveSearch";s:2:"id";s:10:"SaveSearch";}s:10:"_tabOffset";i:0;s:4:"_tab";s:1:" ";s:8:"_lineEnd";s:1:" ";s:8:"_comment";s:0:"";}

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: ID field lacking in hook_civicrm_postProcess
January 10, 2012, 01:18:14 pm

can u please file an issue (and potentially a patch) and we'll fix this for 4.2

The _id value is not being set when a new group is created. This is an easy fix (assign the value as the last line of postProcess (since we need to know if its an update vs a create)

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 (Moderator: Donald Lobo) »
  • ID field lacking in hook_civicrm_postProcess

This forum was archived on 2017-11-26.