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
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | form_build_id-262906-13.patch | 676 bytes | barraponto |
| #9 | form_build_id-262906-6.patch | 852 bytes | davyvdb |
| #6 | form_build_id-262906.patch | 840 bytes | davyvdb |
| #4 | form_build_id.diff | 854 bytes | mooffie |
| announcement.tar_.gz | 9.35 KB | minoura |
Comments
Comment #1
gpk commentedMore info at http://drupal.org/node/262587#comment-857348.
Comment #2
mooffie commented@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).
Comment #3
mooffie commentedI 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...
Comment #4
mooffie commentedAha, I solved the mystery.
node_type_form_submit() too should exclude 'form_build_id' from the variables list.
Comment #5
Anonymous (not verified) commented@mooffie: can you do a patch for 7.x-dev?
Comment #6
davyvdb commentedDrupal 7 patch
Comment #7
dries commentedCommitted to CVS HEAD. Thanks.
Comment #8
gpk commentedWas originally reported against 6.2. Not sure if 5.x is affected.
Comment #9
davyvdb commentedComment #10
davyvdb commentedComment #11
davyvdb commentedTriggering testing.
Comment #13
barrapontoRe-rolling, should work just fine.