Commit 18d532e2 authored by Gábor Hojtsy's avatar Gábor Hojtsy

#172630 by webernet: fix weird errors experienced when using the JS file uploader

parent 06c886d4
......@@ -561,12 +561,15 @@ function upload_js() {
// We only do the upload.module part of the node validation process.
$node = (object)$_POST;
$form_state = array();
// Handle new uploads, and merge tmp files into node-files.
upload_node_form_submit(array(), $form_state);
$node->files = array_merge(isset($form_state['values']['files']) ? $form_state['values']['files'] : array(), upload_load($node));
$files = isset($_POST['files']) ? $_POST['files'] : array();
$node->files = upload_load($node);
if (!empty($form_state['values']['files'])) {
foreach($form_state['values']['files'] as $fid => $file) {
$node->files[$fid] = $file;
}
}
$form = _upload_form($node);
$form += array(
......@@ -580,9 +583,12 @@ function upload_js() {
$form = form_builder('upload_js', $form, $form_state);
// Maintain the list and delete checkboxes values.
$files = isset($_POST['files']) ? $_POST['files'] : array();
foreach ($files as $fid => $file) {
$form['files'][$fid]['list']['#value'] = isset($file['list']) ? 1 : 0;
$form['files'][$fid]['remove']['#value'] = isset($file['remove']) ? 1 : 0;
if (is_numeric($fid)) {
$form['files'][$fid]['list']['#value'] = isset($file['list']) ? 1 : 0;
$form['files'][$fid]['remove']['#value'] = isset($file['remove']) ? 1 : 0;
}
}
$output = theme('status_messages') . drupal_render($form);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment