Set required setting of a field in twig #2038
Replies: 1 comment 8 replies
-
Using {% do form.setFieldSettings('workFeaturedAudio', {
required: true,
}) %}
{% do form.setFieldSettings('workFeaturedAudio', {
required: false,
}) %} Both the above work on my end. As for File Upload fields, they're a little special because of how the browser handles But it sounds like you might also be hooking Formie up to an Entry integration - is that correct? I just want to ensure that we have our submission (the Formie side) and entry (the Craft side) terminology correct. |
Beta Was this translation helpful? Give feedback.
-
Hi all,
I was wondering if it is possible to override the required setting of a field (specifically an upload-field).
I have a form that is being used to create or update a portfolio entry. When there isn't an id-parameter, the form concers a new entry and some fields are required.
When there is an id-parameter, the form gets prefilled and the entry gets updated. I would like to make some of the file-upload field non-mandatory, to prevent the user from having to upload the same file again.
Any idea how I could do this? I've tried:
But that doesn't seem to work, as the field still ends up being required.
And an additional question, how do I then make sure that, when no new file is being provided, the file in the entry remains as is?
In the past, when we tried setting the file-field to optional. But leaving it empty would result in the file being removed from the entry. We would like to avoid that, and simply keep the existing file in the entry when no new one is being provided in the form.
Beta Was this translation helpful? Give feedback.
All reactions