Problem/Motivation

Clicking the Submit button seems silly in this situation, but a major error shouldn't be involved when someone does.

Steps to reproduce:

  1. Install styleguide on a clean copy of Drupal 7
  2. After enabling, visit admin/appearance/styleguide
  3. Find the submit button and click it

You should see a white screen with the error:
Fatal error: Function name must be a string in /[your-directory]/includes/form.inc on line 3534

This error comes from form_validate_machine_name() in form.inc.

Proposed resolution

This happens because a machine_name field is always validated if the submitted value is different than the #default_value. Because there is no #default_value assigned in this module, it will always happen. Even if there was, a user changing it and clicking submit would still trigger this. There needs to be an 'exists' function assigned, as documented in the Form API: http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.ht...

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

guschilds’s picture

As described in the issue description, this patch adds a call to a new function within the styleguide module to determine whether or not the machine_name field already exists. Because this machine_name isn't important, nor is it actually getting used, the function simply returns FALSE.

The error described should no longer happen and the styleguide page will simply reload, just as it does in the 6.x version.

guschilds’s picture

Status: Active » Needs review
agentrickard’s picture

Status: Needs review » Reviewed & tested by the community

Odd bug but proper fix, I suppose. Minor formatting issue with the docblock needs to be cleaned up.

guschilds’s picture

Thanks for reviewing. What is the formatting issue? I can get it cleaned up if needed.

agentrickard’s picture

+ * @param $value
+ * The submitted value.
+ * @param $value
+ *   The submitted value.
guschilds’s picture

Thanks for pointing this out. Had to reread the documentation guidelines.

I fixed the formatting and attempted to make the comments more appropriate and consistent with the rest of the module.

agentrickard’s picture

Status: Reviewed & tested by the community » Fixed

Committed.

   a71a122..6b11e76  7.x-1.x -> 7.x-1.x

Status: Fixed » Closed (fixed)

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