getgrav / getgrav/grav-plugin-form
File upload field JS error on upload initiate
- Dominant language
- PHP
- Stars
- 64
- Forks
- 80
- Avg merge
- 10h 13m
- Merged PRs (30d)
- 9
Description
Using the latest version (v2.15.0) of the forms plugin I am seeing a JS error when attempting to upload files in a front end form.
Error: Uncaught TypeError: Cannot read property 'trim' of undefined
Screen shot attached.

File field in .md file:
`-
name: header_background
label: 'Header Background'
type: file
destination: '@self'
multiple: false
accept:
- image/*
`
Steps to reproduce:
Create a page with a front end form, add a file field with basic config. Navigate to the form page and attempt to upload a file using the form field. The form field will remain empty, and in the console the error will show.
I've tried this across two separate grav sites with the same result.
I've attempted to start debugging this and got as far as the issue being related to the previewTemplate - it appears to not be being set from the dropzone options array, but I'm unsure why.
Let me know if you need further info.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the error in a front-end form using the shown .md file field configuration, then inspect how the previewTemplate is populated in the Dropzone options. Confirm the fix by ensuring the file field accepts an upload without the trim error and no longer remains empty.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, php
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100