I have an hook_form_alter() function:

function announcement_form_alter(&$form, $form_state, $form_id) {

// echo "announcement_form_alter(&$form, $form_state, $form_id) called <br>\n";

  if ($form_id == 'node_type_form' &&   // for node_type_form
     // only for announcement
     $form['#node_type']->type == 'announcement' && 
      isset($form['identity']['type'])) { //  may not be needed

// dprint_r($form);

    $form['announcement_block_max_list_count'] = array(
      '#type' => 'textfield',
      '#title'  => t('Maximum number of block announcements'),
      '#default_value' =>
  variable_get('announcement_block_max_list_count_announcement', 3),
      '#description'   => t('Maximum number of items in block'),
      '#required'      => FALSE,
      '#weight'        => 0
    );

    $form['announcement_display_classification'] = array(
      '#type' => 'checkbox',
      '#title'         => t('Display announcement classification'),
      '#default_value' =>
variable_get('announcement_display_classification_announcement', 1),
      '#description'   =>
        t('Insert the classification in the announcement modules'),
      '#required'      => FALSE,
      '#weight'        => 0
    );
  }
}

Variables announcement_block_max_list_count_announcement and
announcement_display_classification_announcement are now correctly stored and retrieved.

However, one strange variable form_build_id_announcement
is created in table variable:

select * from variable where name like '%announcement%';

| announcement_display_classification_announcement | i:1;
| comment_form_location_announcement | s:1:"0";
| announcement_block_max_list_count_announcement | s:2:"30";
| comment_subject_field_announcement | s:1:"1";
| comment_preview_announcement | s:1:"1";
| comment_controls_announcement | s:1:"3";
| comment_anonymous_announcement | i:0;
| comment_default_per_page_announcement | s:2:"50";
| comment_default_order_announcement | s:1:"1";
| comment_default_mode_announcement | s:1:"4";

| form_build_id_announcement | s:37:"form-d5383d0c1653760c25e871b5c4feed6e";

| comment_announcement | s:1:"2";
| upload_announcement | s:1:"1";
| nodeapi_example_announcement | s:1:"0";
| node_options_announcement

Toshi

Comments

gpk’s picture

mooffie’s picture

@minoura: Visit a settings page for any other content-type (i.e., other than 'announcement'), and submit the form. Is a 'form_build_id_nodetype' variable created for that content-type? (If so, we'll know your code is irrelevant).

mooffie’s picture

I can't actually run Drupal right now, so I can only 'talk'.

I found something interesting in the cvs log:

http://cvs.drupal.org/viewvc.py/drupal/drupal/modules/system/system.modu...

"'form_build_id' should not be saved as a system setting when a setting form is submitted"

So it seems they fixed that bug already. But it was October 2007, and we're talking about D6.2 here, so something is amiss...

mooffie’s picture

Title: Strange Variable is Created by variable_get() in hook_form_alter() » Bogus "form_build_id_/nodetype/" variable created on type settings page
Status: Active » Needs review
StatusFileSize
new854 bytes

Aha, I solved the mystery.

node_type_form_submit() too should exclude 'form_build_id' from the variables list.

Anonymous’s picture

@mooffie: can you do a patch for 7.x-dev?

davyvdb’s picture

Version: 6.2 » 7.x-dev
StatusFileSize
new840 bytes

Drupal 7 patch

dries’s picture

Status: Needs review » Fixed

Committed to CVS HEAD. Thanks.

gpk’s picture

Version: 7.x-dev » 6.x-dev
Status: Fixed » Patch (to be ported)

Was originally reported against 6.2. Not sure if 5.x is affected.

davyvdb’s picture

StatusFileSize
new852 bytes
davyvdb’s picture

Status: Patch (to be ported) » Needs review
davyvdb’s picture

Triggering testing.

Status: Needs review » Needs work

The last submitted patch, form_build_id-262906-6.patch, failed testing.

barraponto’s picture

StatusFileSize
new676 bytes

Re-rolling, should work just fine.

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.