Comments (9)
Hmmm when i change the contenttype settings of upload_bio from
upload_bio:
type: file
to
upload_bio:
type: image
I don't get the string to array error. But the uploaded image path is not displayed in the image field in the admin.
from boltforms.
It is not displayed but it is saved to the database. So i guess type:file doesn't support the way the form sends the data to the database.
from boltforms.
So the data from the form is saved as this in the database:
{"file":"Users/dorien/Projects/bolt/groteprijsnl//Laagje voor laagje.7615ae4d4f2eb7462e251d10.png",
"filename":"Users/dorien/Projects/bolt/groteprijsnl//Laagje voor laagje.7615ae4d4f2eb7462e251d10.png",
"title":"Laagje voor laagje.7615ae4d4f2eb7462e251d10.png",
"basepath":"public/files/uploads"}
When uploading to type:image
through the admin the data is saved as this in the database:
{"file":"2020-01/cat-bowtie.jpg"}
When uploading to type:file
through the admin the data is saved as this in the databae:
2020-01/1578424192_cat-bowtie.jpg
I'm a bit lost in what kind of field type i should save an upload from boltforms. And how to display this in the admin.
from boltforms.
If i could access the title and the pasebath from the database then i could make a clickable link to the document. But when trying to display this field {{ record.upload_bio }}
i get this Users/dorien/Projects/bolt/groteprijsnl//Laagje voor laagje.7615ae4d4f2eb7462e251d10.png
. Not sue if that is the file or the filename. I tried {{ record.upload_bio.title }}
but i can't seem to get the title
from boltforms.
When changing to a database table instead of saving to a contenttype the saved data in the database from file upload looks like this:
/Users/dorien/Projects/bolt/groteprijsnl/public/files/uploads/cat-knudu.d3fa090cfbcc3919c912a802.jpeg
Which is perfect! Why is it saved so different to a contenttype...
from boltforms.
@DorienD Looks like that is a slightly different issue.. in the DB it saves the path on the file system, which is different than how an type: image
field handles it. If you wish to display it in the site, you probably just need to replace the absolute part of the path.. Try:
<img src="{{ record.upload_bio|replace({'/Users/dorien/Projects/bolt/groteprijsnl/public/': '/'}) }}">
from boltforms.
@DorienD I think that for saving more complex fields (usually anything that is not a scalar or non-associative array IIRC) then you are better off extending the form with your own fields based on symfony forms.
from boltforms.
Hmmm I think with the replacing of the absolute part of the path i'm getting really close but!
{{ record.upload_bio|replace({'Users/dorien/Projects/bolt/groteprijsnl//': '/public/files/uploads/'}) }}
Results in this url
http://0.0.0.0:8000/public/files/uploads/Laagje%20voor%20laagje.7615ae4d4f2eb7462e251d10.png
Which i figured would be the right path to access the image, but this gives a 404. So now i think i have to figure out how to access the files folder.
from boltforms.
Ah! I got it! Set management_controller: true
in the boltforms settings and now this works:
{{ record.upload_bio|replace({'Users/dorien/Projects/bolt/groteprijsnl//': '/boltforms/download?file='}) }}
🎉
from boltforms.
Related Issues (20)
- Limit document file upload type HOT 2
- Fix for flash messages breaks redirects
- Feedback Messages inconsistencies with multiple forms HOT 5
- [RFC] Contenttype updating via form HOT 3
- Indentation database example near field_map is wrong when copying
- Saving to a contenttype HOT 2
- Suggestion: make boltforms contain a boltform selector field HOT 2
- Error message when file is too large in size HOT 1
- MP3 compressed to mpga
- Redirect after submission gives error on Chrome & Firefox HOT 1
- Multiple files upload HOT 1
- [Feature Request] Environment variables or bolt parameters in extension configuration file
- Individual form templates aren't used HOT 1
- error while sending a form HOT 1
- from_email not substituted from filed
- Setting ReCaptcha v3 score threshold HOT 6
- recaptcha v3 forms not submitting HOT 1
- Submit form redirect ("Notice: Undefined index: query")
- Unclear debug_address
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from boltforms.