By NewToDruballer on
Hi,
I have a problem with creating forms. My code (just relevant parts, as I think):
function user_gallery_menu($may_cache) {
$items[] = array(
'path' => 'usergallery/admin',
'title' => t('adminarea images'),
'callback' => '_user_gallery_admin',
'access' => true,
'type' => MENU_NORMAL_ITEM
);
return $items;
}
function _user_gallery_admin() {
$themeingstring=theme(...);
return drupal_get_form('user_gallery_frm').$themingstring;
}
function user_gallery_frm() {
$form=array();
$form['#attributes'] = array("enctype" => "multipart/form-data");
$form['image'] = array('#type' => 'file', '#title' => t('Image'), '#weight' => -3);
$form['submit']=array('#type'=> 'submit', '#value'=>'Hochladen');
return $form;
}
function user_gallery_frm_validate($form_id, $form_values) {
//validation
}
function user_gallery_frm_submit($form_id, $form_values) {
drupal_set_message('submitted');
cache_clear_all();
}
After submitting the form the first time, the message "submitted" appears as I wanted. After submitting the same form again (where I have been redirected to), no message appears. And it seems, neither the validation nor the submit-function are called. So I entertained suspicion, that the page was cached. But when I turned off caching, it is still not submiting.
When I rename the complete formname and its hooks(for example "user_gallery_frm1"), the same is happening. It submits the form once and the next time it wont submit.
Can anybody help me, what I did wrong?
Thanks in advance.
Markus
Comments
Its not a bug, its a feature
Its not a bug, its a feature... I fear.
I wanted it to be possible to send the form one time to upload one image, and after that, upload another image with the same form. But because a token is generated from the forms name (here 'user_gallery_frm'), and it is always the same of course, drupal thinks, it was mistakenly submitted twice. But how can I now allow my users, to submit the same form (but with different values) again?
Thanks in advance
Development version of Drupal?
It seems you are using a non released Drupal version from CVS (5.x-dev). It's best to use 5.1. Alternatively, upgrade to todays 5.x-dev.
--
The Manual | Troubleshooting FAQ | Tips for posting | How to report a security issue.
*Argh* You were right. The
*Argh*
You were right. The documentation of one module told me to upgrade to CVS-Version because of a bug or something. *biting into my foot*
That cost me one day. At least, I know no many lines of Drupalcorecode by name :-D
Thank you very much.
Markus