Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Forms & Blueprints

Attachment / File Destination for uploads in a form

Started by Dean Bateman 3 years ago · 1 replies · 337 views
3 years ago

I have created a form that requires users to upload files

YAML
attachments:
          label: Attachments
          type: file
          multiple: true
          limit: 10
          destination: 'user/data/ServiceForm/files/{{ form.value.project_name|e }}'

I have used the destination field, but it will typically only save in one single folder,

I am trying to use a form value to create a custom folder within the user data folder

this code above just created a folder called '{{ form.value.project_name|e }}' instead of using the form value of the project name

this of course didn't work, but any clever people out there know how this could be achieved or if I am missing something simple.

Thanks

update:

tried adding

YAML
process:
  twig: true
cache_enable: false

but didnt work

last edited 09/11/23 by Dean Bateman
3 years ago

@dean_007, The value of 'destination' is not being processed using Twig. It is used 'as is'.

Using a plugin you might be able to process the Twig string yourself during one of the events raised by the Form plugin and update the value of 'destination' field before the file is being saved.

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by Ton Haarmans, 5 years ago
13 1136 4 months ago
Forms & Blueprints · by Hugo Oliveira, 5 months ago
0 61 5 months ago
Forms & Blueprints · by Flachy Joe, 6 months ago
9 135 6 months ago
Forms & Blueprints · by Augustus, 7 months ago
7 110 7 months ago
Forms & Blueprints · by Julien, 7 months ago
10 129 7 months ago