Closed nilshoerrmann closed 2 years ago
Noticed this as well. On 3.2.0. However, file uploading seems to be working fine.
Same Issue, File upload seems fine, but file selection is not working...
Same issue here.
... and here on 3.3.0
Ah, I came to create the same issue and will write it out here so it actually appears in search:
Invalid file model type: kirby-builder/pages ...
I'm on Kirby 3.3.0
I'm trying to look into this a bit further as it's really blocking me from shipping a project using builder.
Looking at the network requests, the builder textarea filepicker makes a call like so: https://DOMAIN/api/kirby-builder/pages/SLUG/fields/FIELD_NAME/files?page=0
which fails with the Invalid file model type
400 error.
A default textarea makes the call like so: https://DOMAIN/api/pages/SLUG/fields/FIELD_NAME/files?page=0
which of course works.
Looking at the codebase, it looks like the url is set here https://github.com/TimOetting/kirby-builder/blob/88c6d13ba96cd3a68fb57c6567fb69fb61201560/src/components/BuilderBlock.vue#L291 but I'm at a bit of a wall at this point.
The only solution (clearly a terrible one) I've found is hard-coding the path to a known working endpoint:
field: `kirby-builder/${modelEndpoint}/fields/${this.blockPath}+${fieldSet.fields[fieldName].name}`,
to
field: `kirby-builder/${modelEndpoint}/fields/EXISTING_DEFAULT_TEXTAREA_NAME`,
@TimOetting I am sorry to bug you but any tips would be greatly appreciated as I am completely stuck here.
Ok, this is my absolutely terrible solution for now, unless @TimOetting or someone else can let me know the right way to fix this bug.
In the root of the kirby-builder
folder, I define a .env.local
file:
DEFAULT_TEXTAREA=text
BUILDER_TEXTAREAS=some,builder,textareas
Where DEFAULT_TEXTAREA
is the name of a default textarea field that exists in the blueprint, and BUILDER_TEXTAREAS
are the names of builder textarea fields.
Then changed https://github.com/TimOetting/kirby-builder/blob/88c6d13ba96cd3a68fb57c6567fb69fb61201560/src/components/BuilderBlock.vue#L290 to:
if (process.env.BUILDER_TEXTAREAS.split(',').indexOf(fieldName) >= 0) {
fieldSet.fields[fieldName].endpoints = {
field: `${modelEndpoint}/fields/${process.env.DEFAULT_TEXTAREA}`,
model: modelEndpoint,
section: this.endpoints.section
};
} else {
fieldSet.fields[fieldName].endpoints = {
field: `kirby-builder/${modelEndpoint}/fields/${this.blockPath}+${fieldSet.fields[fieldName].name}`,
model: modelEndpoint,
section: this.endpoints.section
};
}
Then npm run build
for the production build.
It's odd that file
fields work without issue.
thanks @alancwoo that actually worked! i can use this as a workaround. one thing that messed me up though: your first line says:
if (process.env.BUILDER_TEXTAREAS.split(',').indexOf(fieldName) >= 0) {
i needed to change it to double brackets as in
if (process.env.BUILDER_TEXTAREAS.split(",").indexOf(fieldName) >= 0) {
then, after npm run build
it worked. sadly this hack needs an otherwise useless simple textarea to be present and needs to be updated once the blueprint is changed.
btw, there is a response regarding this topic by @TimOetting in the kirbyforum: https://forum.getkirby.com/t/error-message-when-selecting-file-in-textarea/13568/5
seems like the problem could be in kirby-core? but i am not really sure about that.
Closing this issue because this plugin will no longer be maintained, as its main functionality can be replaced by Kirby's built-in Blocks Field and Layout Field.
We are using a textarea inside the builder and would like to select images via the toolbar, see https://getkirby.com/docs/reference/panel/fields/textarea#file-upload-and-select. This results in the following error:
Here is a reduced version of our blueprint:
My guess is that the context
page.images
is wrong given the nested structure: How do we have to define thefiles
options to enable image selection?