I have a form that is loaded in a panels pane configuration modal dialog and the form uses fields. Generally the form works just as expected unless an imagefield or filefield widget is added to the form. Uploading an image breaks the form. If the form is filled out and an image is selected, but the "upload" button is not clicked everything operates according to plan. The problem is created when the "upload" button on the file field widget is clicked. The image will upload as expected and the form can then be submitted, however none of the form elements are saved and the submit handler for the form is never executed.
A dpm() of $form_state and $form inside of the drupal_process_form() function that is called at submit time yields a few key differences in the state of the form.
$form and $form_state differences in the scenario that doesn't work
$form['#submit'][0] = 'fieldable_panels_panes_fieldable_panels_pane_content_type_edit_form_submit';
$form_state['submit_handlers'][0] = 'file_managed_file_submit';
$form_state['submit_handlers'][1] = 'file_field_widget_submit';
$form_state['values'] = array(
field_image,
field_image_und_0_upload_button,
);
$form and $form_state differences in the scenario that does work
$form['#submit'][0] = 'fieldable_panels_panes_fieldable_panels_pane_content_type_edit_form_submit';
$form['#submit'][1] = 'ctools_wizard_submit';
$form_state['submit_handlers'] // doesnt exist;
$form_state['values'] = array(
'return',
'cancel',
'title',
'field_body',
'field_image',
'form_build_id',
'form_token',
'form_id',
'op',
);
So i have dug as deep as drupal_process_form() a little bit into that function form_execute_handlers is executed, and according to its source if $form_state['submit_handlers'] exists it executes those callbacks and ignores $form['#submit'] which explains why my submit functions are not getting called. And based on the state of $form and $form_state im guessing that when the upload button is clicked, its ajax event is called, it does what is required to upload the file and set the form state, but the form is not getting rebuilt after the ajax callback returns its data. This is my best guess at least.
This is were the water gets murky for myself. How could ctools be impacting this form and preventing the proper submission of this form?
Any help would be greatly appreciated.
Comments
Comment #1
rerooting commentedI am having trouble with this myself. Any luck?
Comment #2
drupal_was_my_past commentedI'm having this problem too. Has anyone figured this out?
Comment #3
Ashlar commented@rerooting In order to assist you we need additional information. Please review the drupal.org/node/571990 'Submission Checklist' for the type of information we are looking for. When you post information, please change the status back to active. Thanks.
Comment #4
Ashlar commented@rerooting In order to assist you we need additional information. Please review the drupal.org/node/571990 'Submission Checklist' for the type of information we are looking for. When you post information, please change the status back to active. Thanks.
Comment #5
drupal_was_my_past commented@Ashlar, @rerooting,
I figured out what was causing my problem. I was doing some form altering and conditional checks in a
hook_form_alter(). Clicking Upload on the file uploader causes the form to be rebuilt using the $form_state variables so all of my conditional checks based on $form_state variables, including my ajax form submit, failed.Comment #6
merlinofchaos commentedFun fun fun. I assume from #5 that means we can mark this fixed and hope that you were able to fix the problem in your code.