Skip to content
Snippets Groups Projects
class.forms.php 66.9 KiB
Newer Older
  • Learn to ignore specific revisions
  •           maxfilesize: <?php echo ($config['size'] ?: 1048576) / 1048576; ?>,
    
              name: '<?php echo $name; ?>[]',
              files: <?php echo JsonDataEncoder::encode($files); ?>
            });});
            </script>
    <?php
        }
    
        function getValue() {
            $data = $this->field->getSource();
    
            $ids = array();
            // Handle manual uploads (IE<10)
            if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_FILES[$this->name])) {
                foreach (AttachmentFile::format($_FILES[$this->name]) as $file) {
    
                    try {
                        $ids[] = $this->field->uploadFile($file);
                    }
                    catch (FileUploadError $ex) {}
    
                }
                return array_merge($ids, parent::getValue() ?: array());
            }
    
            // If no value was sent, assume an empty list
    
            elseif ($data && is_array($data) && !isset($data[$this->name]))
    
                return array();
    
            return parent::getValue();
        }
    }
    
    
    class FileUploadError extends Exception {}