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 &$form as parameter, as in the following code:
function payment_details(&$form) {
$form['payment_details']['amount'] = array(
'#title' => t('Payment Amount'),
'#type' => 'textfield',
);
}
I then call the function in my form definition.
transaction_form() {
// ...
payment_details(&$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?