#172630 by webernet: fix weird errors experienced when using the JS file uploader
parent
06c886d45b
commit
18d532e214
|
@ -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,10 +583,13 @@ 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) {
|
||||
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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue