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):
And in the request object I have:
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
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.
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!
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?
Just an import/export page for bulk editing something with CSVs. Unless you have a more elegant solution available? π
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.
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 π
Cool, I wrap this up by saying a singleton module can also be useful to leverage all twill forms functionality for custom stuff