[development] Forms API: Duplication of "#prefix" string in elements of type "weight"

Syscrusher scott at 4th.com
Fri Nov 25 03:48:13 UTC 2005


On Thursday 24 November 2005 22:25, Syscrusher wrote:
> Good evening, all.
> 
> I'm not sure how to go about reporting this issue, but I've found that the new
> forms API is duplicating the value of #prefix on form elements of type "weight".
[...]
> 
> I'm looking to see if I can find the cause and contribute a patch, but wanted
> to make the team aware of the problem.

Bingo!

The problem was that form_render() was being called from theme_weight as well
as from drupal_get_form(). Each call appended the prefix and appended the suffix,
so you were actually getting this:

          $PREFIX $PREFIX $FORM_STUFF $SUFFIX $SUFFIX

I happened not to notice the extra suffix at first in the HTML output, but it
was there.

All that was needed was a pair of unset() calls added to theme_weight().

Under the "code is gold" premise, I've filed this as an issue (#38790) and have
contributed a patch to includes/form.inc.

I hope the forms API team find this helpful. Great piece of code, other than
this little glitch.

Scott

-- 
-------------------------------------------------------------------------------
Scott Courtney     Drupal user name: "syscrusher"   http://drupal.org/user/9184
scott at 4th dot com       Drupal projects: http://drupal.org/project/user/9184
Sandbox:  http://cvs.drupal.org/viewcvs/drupal/contributions/sandbox/syscrusher


More information about the development mailing list