Domanda

I have some code from a training course, where I am studying Drupal Module Development. I am using the Form API which wants the $form_state to be passed by reference. That means that I enter the variable as &$form_state. I did that, so I cannot figure out why I am getting an error that reads:

Warning: Parameter 1 to form_fun_cake() expected to be a reference, value given in
drupal_retrieve_form() (line 806 of /media/sf_sandbox/drupal-mod-dev/includes/form.inc).

The form is just manufactured for training purposes. I pasted it here: http://pastebin.com/A8VsBzsL

The error suggests that the problem is not originating in my code, other than the fact that Parameter 1 to form_fun_cake() is the code inside my own /sites/all/modules/custom/form_fun/ I have put this into two separate drupal installations with the same result. Of course, both are from the same code base of Drupal core, version 7.26. Any suggestions? Any idea why Drupal would report that the parameter is not passed by reference?

Thanks,

Bruce

È stato utile?

Soluzione

You're just missing the $form argument:

function form_fun_cake($form, &$form_state) {
  ...
}

It's possible the code you're adapting was meant for Drupal 6.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top