Although a link to the admin page is present (admin/config/people/fboauth) in the People menu, no form is rendered when the page is visited. I'm getting the following error:

Warning: Parameter 1 to fboauth_settings_form() expected to be a reference, value given in drupal_retrieve_form() (line 772 of /Applications/MAMP/htdocs/aetta_exp/includes/form.inc).

fboauth_settings_form() takes only a &$form_state array:

function fboauth_settings_form(&$form_state) {

If I add in a $form parameter, it seems to fix the issue:
function fboauth_settings_form($form, &$form_state) {

I'll attach a patch in my next post.

CommentFileSizeAuthor
#1 admin-form-missing-1305340-1.patch451 bytesareynolds

Comments

areynolds’s picture

Status: Active » Needs review
StatusFileSize
new451 bytes
Adam S’s picture

No passing by reference :) Patch works for me.

quicksketch’s picture

Although a link to the admin page is present (admin/people/fboauth) in the People menu, no form is rendered when the page is visited.

Is the admin page really at "admin/people/fboauth"? It should be at admin/config/people/fboauth.

This patch is definitely correct, but for some reason I don't see it on my local. Weird. But definitely a good patch, I'll give this a look when I get the chance.

areynolds’s picture

You're right, it's at admin/config/people/fboauth (I made a typo in the issue post), but without that $form parameter I just get a blank page, no form. Considering the error, could it depend on the PHP version or configuration? In any case, I don't think there's any problem with adding the extra parameter.

quicksketch’s picture

Considering the error, could it depend on the PHP version or configuration?

Yeah probably so. I still run PHP 5.2 on my local. The patch is correct in any case.

phantom21’s picture

I was getting the same error so I applied the patch in #1and it went away. However, after reading the code, it seems to me that the correct fix would be to make the following change:
-function fboauth_settings_form(&$form_state) {
+function fboauth_settings_form($form_state) {

I tried this and it works too. The patch posted in #1 should not create any problem, but logically it did not seem right to me.

areynolds’s picture

Passing $form_state by reference makes sense to me. It keeps the persistent state of the form and is passed around to a lot of functions in the Form API. Indeed, I think most (if not all) of the Form API functions use $form_state in that manner.

As for including $form, I guess I just learned to write my form declarations that way. I don't think it's required, I just saw it in the Drupal 7 Module Development book and on some of the Form API documentation. Many of the core modules use it as well, but I never really wondered why.

I'm trying to think of reasons why you'd want $form in the form declaration. Perhaps it's handy when performing AJAX functions on the form and you need to add to/rebuild parts of the form structure? I'd be intrigued to see specific examples of how this gets used.

Adam S’s picture

I think you have to use both parameters $form and $form_state. If you just use $form_state, it is really the $form being renamed and the $form_state can be accessed using func_get_arg().

I'm not sure if it is true in this case because forms are arrays and not objects but objects are passed by reference automatically in php 5.2 and higher which is why 5.2 is required for Drupal 7. http://drupal.org/node/224333#php_version

phantom21’s picture

You are right. After reading the code in more detail, I see that a lot of other functions are declared that way, even when one of the arguments is not used anywhere in a function :-)

quicksketch’s picture

Status: Needs review » Fixed

Committed patch in #1. Thanks again areynolds!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Typo: path is admin/config/people/fboauth, not admin/people/fboauth.