Attached patch adds the following line about the form id to the Forms API quickstart guide.

Because the form ID can be used in functions, you have to make sure it is a valid PHP label. A valid form ID starts with a letter or underscore, followed by any number of letters, numbers, or underscores.

Though form IDs do not have to be valid PHP labels per se (see eg CCK), invalid form IDs break a good deal of FAPI.

CommentFileSizeAuthor
#4 fapi_valid_formid_0.txt2.21 KBheine
fapi_valid_formid.txt2.19 KBheine

Comments

heine’s picture

Status: Active » Needs review

status (though it's not exactly code)...

Gary Feldman’s picture

Because the form ID can be used in functions, you have to make sure it is a valid PHP label

As written, that's a non-sequitur. Any string can be used within a function without being a valid PHP variable name. I think what you mean to say is more like:

Becuase the form ID might be used to construct the name of a function, it must be a valid PHP variable name. It should start with a letter or underscore, followed by any number of letters, numbers, or underscores; spaces are not allowed.

Gary

RobRoy’s picture

I think dashes would be a big mistake as well:

Becuase the form ID might be used to construct the name of a function, it must be a valid PHP variable name. It should start with a letter or underscore, followed by any number of letters, numbers, or underscores; spaces and dashes are not allowed.

heine’s picture

StatusFileSize
new2.21 KB

Thanks, function names is indeed what I meant to say. Attached a new patch.

The sentence "A valid form ID starts with a letter or underscore, followed by any number of letters, numbers, or underscores." indicates that spaces and dashes are not allowed.

coltrane’s picture

Status: Needs review » Needs work

Bump, this still isn't documented from what I can find and I just ran into it. drupal_get_form() takes one argument now.

betz’s picture

Project: Documentation » Drupal core
Version: » 7.x-dev
Component: Documentation in CVS » documentation
jhodgdon’s picture

The patch doesn't apply any more for Drupal 6 or 7 (the doc has been changed slightly). But I've added the above sentence, more or less, to the doc for D6 and D7.

Changes checked into the contrib repository today; should show up on api.drupal.org within a day or two. See http://drupal.org/cvs?commit=229292 and http://drupal.org/cvs?commit=229288

jhodgdon’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

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