Uniform and dropzone

i am using one form-element for uniform (https://github.com/mzur/kirby-uniform) from @mzur to post data with a submit button. this works well alone.
i also have a form element for dropzone.js (https://github.com/enyo/dropzone), which does not have a submit button. the form uploads the files correctly.

but once i use dropzone to upload a file. the submit button does not send the uniform data anymore.

maybe the uniform token gets rejected? any ideas how to find out more?

this is how my controller looks…

$form = uniform('datensatz', [
    'required' => [],
    'guard' => '', // disabled, has authentification
    'actions' => [
            '_action' => 'log',
            'file' => './upload/datensatz.log'

if(!empty($_FILES) && !isset($_POST["_submit"])) {
    $upload = upload(
        $page->root() . DS . '{safeName}.{safeExtension}', 
            'accept' => 
            function($media) {
                $ext = f::mimeToExtension(f::mime($media->root()));
                return in_array($ext, array('jpeg', 'jpg', 'pdf'));
    if(!$upload->error) {
        $data = [ 'filename' => $upload->file()->filename(), ];
        die(response::json($data, 200));

That’s most likely it. The token gets regenerated every time the form is generated, so basically every time you call uniform(). What you could do is to make sure that the file upload does not initialize the form again.

yes @lukasbestle. i just needed to move the upload-logic before the uniform call to get it working. thanks.

1 Like