Browse Source

[UPDATE] introduce dropzone export values method

experimental
Georgi Hristov 4 years ago
parent
commit
2a46d4c409
2 changed files with 23 additions and 22 deletions
  1. +21
    -0
      modules/Utils/FileUpload/Dropzone.php
  2. +2
    -22
      modules/Utils/RecordBrowser/RecordBrowser_0.php

+ 21
- 0
modules/Utils/FileUpload/Dropzone.php View File

@@ -197,4 +197,25 @@ class Utils_FileUpload_Dropzone extends Module
}
$this->set_module_variable('hist', $curr_hist);
}
public static function export_values($form) {
$ret = [];
foreach (self::get_registered_file_fields($form) as $file_field => $file_module) {
$files = [];
$uploaded_files = $file_module->get_uploaded_files();
foreach ($uploaded_files['existing'] as $file) {
if (isset($uploaded_files['delete'][$file['file_id']])) continue;
$files[] = $file['file_id'];
}
foreach ($uploaded_files['add'] as $file) {
$files[] = [
'filename' => $file['name'],
'file' => $file['file']
];
}
$ret[$file_field] = $files;
$file_module->clear_uploaded_files();
}
return $ret;
}
}

+ 2
- 22
modules/Utils/RecordBrowser/RecordBrowser_0.php View File

@@ -1078,28 +1078,8 @@ class Utils_RecordBrowser extends Module {
$form->freeze($args['id']);
}
if ($form->exportValue('submited') && $form->validate()) {
$values = $form->exportValues();

/**
* @var Utils_FileUpload_Dropzone $file_module
*/
foreach (Utils_FileUpload_Dropzone::get_registered_file_fields($form) as $file_field => $file_module) {
$files = [];
$uploaded_files = $file_module->get_uploaded_files();
foreach ($uploaded_files['existing'] as $file) {
if (isset($uploaded_files['delete'][$file['file_id']])) continue;
$files[] = $file['file_id'];
}
foreach ($uploaded_files['add'] as $file) {
$files[] = [
'filename' => $file['name'],
'file' => $file['file']
];
}
$values[$file_field] = $files;
$file_module->clear_uploaded_files();
}
$values = array_merge($form->exportValues(), Utils_FileUpload_Dropzone::export_values($form));

foreach ($defaults as $k=>$v) {
if (!isset($values[$k]) && ($this->view_fields_permission === false
|| (isset($this->view_fields_permission[$k]) && !$this->view_fields_permission[$k]))) $values[$k] = $v;


Loading…
Cancel
Save