TC
Twill CMSβ€’13mo ago
martinph

Handling of a17-filefield response

Hi guys, I have a custom CMS page using the a17-filefield input, how do I handle the response of field in the Request object? In my blade file I have (copied from the docs):
<a17-filefield name="input6"></a17-filefield>
<a17-filefield name="input6"></a17-filefield>
And in the request object I have:
"input6_2" => "2"
"input6_2" => "2"
Can I safely assume that "2" as the value refers to the ID in the twill_files table? Is the input name always suffixed by this ID also (input6_2)?
7 Replies
ifox
ifoxβ€’13mo ago
Hi @martinph fields are not necessarily optimized to be used outside of the standard Vuex store flow that transforms the fields data into the payload that Twill is processing. So when you're using the fields on a custom page, it is using a standard form post, and as you identified the keys/values are not "clean". But your assumption is correct.
martinph
martinphβ€’13mo ago
That's great thanks for clarifying. I'm using the Twill fields as it provides consistency for our editors. I'll clean up the inputs on the backend and fetch the file rows accordingly. Thanks again!
ifox
ifoxβ€’13mo ago
Sounds good, and makes sense. We aim to refactor Twill's UI components to be a lot more flexible to be used in custom pages and outside of Twill in the future. Right now they are tied to the core implementation. But can still be used with some tweaks! I'm curious, may I ask what you are building on a custom page?
martinph
martinphβ€’13mo ago
Just an import/export page for bulk editing something with CSVs. Unless you have a more elegant solution available? πŸ˜…
kallefrombosnia
kallefrombosniaβ€’13mo ago
You can make normal HTML input for files which will work in custom pages (you can style it too). After that hadling files on submit is pretty much plain Laravel file handling.
martinph
martinphβ€’13mo ago
I considered that, but I fancied trying this out to be honest (just because, and to get a better idea of Twill). I'll no doubt end up doing it that way after all probably πŸ˜„ Thanks all for your help. Feel free to mark this as solved πŸ™‚
ifox
ifoxβ€’13mo ago
Cool, I wrap this up by saying a singleton module can also be useful to leverage all twill forms functionality for custom stuff