Using form elements for various forms in Drupal 7 I am building a site with several forms that partly contain identical building blocks (for example a fieldset 'payment details'). Ideally, I would like to design my form elements separately and then inject them into each form. My idea was to create functions with &amp;$form as parameter, as in the following code:  

function payment_details(&amp;$form) {  
  $form['payment_details']['amount'] = array(  
    '#title' =&gt; t('Payment Amount'),  
    '#type' =&gt; 'textfield',  
  );  
}


I then call the function in my form definition.

transaction_form() {  
  // ...  
  payment_details(&amp;$form);  
  // ...  
  return $form;  
}  


While the approach leads to the desired result, Drupal gives me the following warning:


  Deprecated function: Call-time pass-by-reference has been deprecated in drupal_load() (line 1100 of C:\Wamp\www\paradise\includes\bootstrap.inc).


Maybe anyone can give me a better way to reach my goal? At least, can you guys advise on how to fix this problem? I understand from various forum posts that this is a PHP related issue, and that it can be more or less ignored for development. Do you agree?
Your function already accepts the $form variable by reference (function payment_details(&amp;$form)) so you don't have to pass the $form element by reference when calling that function. Just use payment_details($form); in your form builder and you should be fine. Passing by reference is deprecated in recent PHP versions, so that's why you get a warning.