getgrav / grav-plugin-form

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

file upload (dropzone) with validate: required can not be submitted #499

Closed stephan-strate closed 2 years ago

stephan-strate commented 3 years ago

Creating a file upload (frontend form) with required: true leads to form being not submittable (with file selected and without). Error in console: An invalid form control with name='' is not focusable.. Tried to investigate it myself, but did not find any documentation on making dropzone fields required. In Grav documentation it is listed as a valid common attribute. It also marks the field as required using *.

Example code:

form:
  name: testform
  buttons:
    submit:
      value: Send
      type: submit
  fields:
    -
      label: File
      name: myfile
      type: file
      destination: user/data/form
      accept:
        - '*'
      multiple: false
      filesize: 10
      avoid_overwriting: true
      random_name: false
      validate:
        required: true
  process:
    save:
      body: '{% include ''forms/data.txt.twig'' %}'
      operations: add
      filename: form.txt

Versions: Grav: v1.7.6 Form: v5.0.0 (did not work in version before as well)

mahagr commented 3 years ago

Yeah, required doesn't work with any file fields.

stephan-strate commented 3 years ago

Yeah, required doesn't work with any file fields.

Thanks for confirmation. Do you think this is something that can be fixed? Just want to ask before I dig into it.

mahagr commented 3 years ago

It is somewhat tricky to fix as the form is also used to save existing data. I think it is possible to get it working, though.

crinavar commented 3 years ago

Hi, any plans on fixing this? having the same problem

hughbris commented 2 years ago

Duplicate of #418

mahagr commented 2 years ago

Closing as duplicate.