getgrav / grav-plugin-form

Grav Form Plugin
http://getgrav.org
MIT License
53 stars 79 forks source link

Grav frontend file uploading not working properly #550

Open geogeorgejoseph opened 2 years ago

geogeorgejoseph commented 2 years ago

Created a grav frontend form with file uploading feature. Except file upload everything working fine. When i trying to upload file, getting some errors from 'form.vendor.js' and file field seems to be empty after getting error. Errors given below

form.vendor.js:5 Uncaught TypeError: Cannot read properties of undefined (reading 'trim')
    at D.addedfile (form.vendor.js:5:11362)
    at D.value (form.vendor.js:5:1513)
    at D.value (form.vendor.js:5:25886)
    at HTMLInputElement.<anonymous> (form.vendor.js:5:17561)  

Form full definition given below

title: 'Job apply form'
published: true
body_classes: job-apply-main-page
cache_enable: false
visible: true
form:
    name: job-apply
    id: job-apply
    action: ' '
    fields:
        -
            name: job
            label: Job
            autocomplete: 'off'
            type: text
            validate:
                required: false
        -
            name: applicantName
            label: 'Name of Applicant *'
            autocomplete: 'off'
            type: text
            validate:
                required: true
                message: 'Please enter the applicant name'
        -
            name: email
            label: Email
            type: email
            validate:
                required: false
        -
            name: coverletter
            label: 'Cover Letter'
            type: textarea
            validate:
                required: false
        -
            name: resumefile
            label: Resume
            placeholder: 'Upload Resume'
            type: file
            destination: user/data/resume
            accept:
                - .pdf
                - .doc
                - .docx
            multiple: false
        -
            name: toEmail
            label: 'Hidden Field'
            type: text
            outerclasses: hide-input-field
            validate:
                required: false
        -
            name: enquiry-g-recaptcha-response
            label: Captcha
            type: captcha
            id: enquiry-captcha
            outerclasses: captcha-field
            recaptcha_not_validated: 'Captcha not valid!'
            validate:
                required: true
    buttons:
        -
            type: submit
            value: Save
    process:
        -
            email:
                subject: '{{form.value.hiddenField}}'
                from: '{{ config.plugins.email.from }}'
                to:
                    - test@gmail.com
                body: '{% include ''forms/data.html.twig'' %}'
                attachments:
                    - resumefile
        -
            email:
                subject: '{{form.value.hiddenField}}'
                from: '{{ config.plugins.email.from }}'
                to:
                    - '{{ form.value.email }}'
                body: '{% include ''forms/apply.html.twig'' with { "message": "Thank you for your Inquiry. We will get back you soon" } %}'
        -
            save:
                fileprefix: feedback-
                dateformat: Ymd-His-u
                extension: txt
                filename: site-enquire.txt
                operation: add
                body: '{% include ''forms/data.txt.twig'' %}'
                attachments:
                    - resumefile
        -
            message: 'Thank you for your feedback!'
            reset: true

Grav and other plugins updated to latest version

Grav v1.7.27.1 Admin v1.10.27 Form v5.1.4

michaelschoenbaechler commented 1 year ago

Had a similar issue, was trying for hours. It worked for me when I removed "reset: true". With "reset: true" the file was not saved at its destination.