Using form elements for various forms in Drupal 7
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.