Answers.Body: <p>Found  an answer here <a href="https://wiki.civicrm.org/confluence/display/CRMDOC/Update+custom+fields+in+contributions+and+events+by+passing+variables+in+a+URL" rel="nofollow">https://wiki.civicrm.org/confluence/display/CRMDOC/Update+custom+fields+in+contributions+and+events+by+passing+variables+in+a+URL</a></p>
  
  <p>Nothing to do with  CRM_Utils_Array though; just plain simple passing vars via an URL.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-16T08:48:27.163Z
Answers.LastActivityDate: 2016-03-16T08:48:27.163Z
Answers.UserDisplayName: yurg
Body: <p>There is a  <a href="https://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_buildForm" rel="nofollow">https://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_buildForm</a> manual page, but not sure I've got it right. </p>
  
  <p>Say, there is a value in a custom function, which should be set as default in a form, built using  hook_buildForm (where form itself opens in a modal frame and outside civicrm/ path).</p>
  
  <p>I've a suspicions <strong>CRM_Utils_Array::value</strong> might be used to set a custom variable somewhere (anywhere) and get it later on wherever it  might be needed; </p>
  
  <p>Have an attempt to <strong>set value outside of hook_buildForm</strong> like this: </p>
  
  <pre><code>$myVeryOwnPid = CRM_Utils_Array::value('myveryownpid', $contact['contact_id_b'], $contact['contact_id_b']); 
  </code></pre>
  
  <p>and <strong>get it from inside hook_buildForm</strong>: </p>
  
  <pre><code>  $myVeryOwnPid = CRM_Utils_Array::value('myveryownpid', $_GET, '0');
  </code></pre>
  
  <p>..but, of course, nothing works, just because I clearly don't understand, how it should work. As they say, CRM_Utils_Array is the most often used feature in CiviCRM, but digging inside a source code Ive realized there is no forest for the trees (at least, for me). Any advice, please!      </p>
  
Tags: <hooks><php><quickform>
Title: CRM_Utils_Array::value how to set value to a hook_buildForm?
ThreadText: # CRM_Utils_Array::value how to set value to a hook_buildForm?
  
  (Asked by: username_0 on 2016-03-15)
  
  There is a  https://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_buildForm manual page, but not sure I've got it right. 
  Say, there is a value in a custom function, which should be set as default in a form, built using  hook_buildForm (where form itself opens in a modal frame and outside civicrm/ path).
  I've a suspicions CRM_Utils_Array::value might be used to set a custom variable somewhere (anywhere) and get it later on wherever it  might be needed; 
  Have an attempt to set value outside of hook_buildForm like this: 
  $myVeryOwnPid = CRM_Utils_Array::value('myveryownpid', $contact['contact_id_b'], $contact['contact_id_b']); 
  
  and get it from inside hook_buildForm: 
    $myVeryOwnPid = CRM_Utils_Array::value('myveryownpid', $_GET, '0');
  
  ..but, of course, nothing works, just because I clearly don't understand, how it should work. As they say, CRM_Utils_Array is the most often used feature in CiviCRM, but digging inside a source code Ive realized there is no forest for the trees (at least, for me). Any advice, please!
  
  **Tags:** hooks, php, quickform
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2016-03-16. Score: 0 | Accepted answer
  
  Found an answer here <https://wiki.civicrm.org/confluence/display/CRMDOC/Update+custom+fields+in+contributions+and+events+by+passing+variables+in+a+URL>
  
  Nothing to do with CRM\_Utils\_Array though; just plain simple passing vars via an URL.
  
  
  ---
  
  