Closed agrislaicans closed 9 months ago
Hi @agrislaicans this is probably missing clarification in the docs but the Medias field is not supported in the create form. Your code should definitely work in the edit form.
If you would like to require that the mediables are stored during the creation of the record instead of during subsequent updates, you can use skipCreateModal()
in your setUp
method so that the first save will include all fields in the payload. The modal will still show up on top of the edit form, but the record won't be saved until the user actually saves the record.
We could technically support medias and other more complex fields in the create form, but the UX isn't ideal in that modal. Happy to review a PR if you are still looking for the ability to do it knowing the above.
Hi @agrislaicans this is probably missing clarification in the docs but the Medias field is not supported in the create form. Your code should definitely work in the edit form.
If you would like to require that the mediables are stored during the creation of the record instead of during subsequent updates, you can use
skipCreateModal()
in yoursetUp
method so that the first save will include all fields in the payload. The modal will still show up on top of the edit form, but the record won't be saved until the user actually saves the record.We could technically support medias and other more complex fields in the create form, but the UX isn't ideal in that modal. Happy to review a PR if you are still looking for the ability to do it knowing the above.
Thanks for such a fast response! Yes, I just discovered this on my own literally as I received notification about your reply.
This actually is perfectly fine and I get your point! Thank you once again.
Description
In
getCreateForm
methos at extendedBaseModuleController
class, addingMedias::make()->name('cover')->label('Cover image')
is not saving uploaded image (not saved in twill_mediables table as well as not passed in form payload)Steps to reproduce
Create a model
Blog
, addHasMedias
trait. In model, define$mediasParams
:Add
HandleMedias
trait inBlogRepository
. AddgetCreateForm
function inBlogController
:Expected result
Selected media image gets passed in form payload and saved in
twill_mediables
tableActual result
Every field gets passed in payload, except
medias
, selected media is not being handled and is not saved intwill_mediables
Versions
Twill version: 3.0.2
Laravel version: 10.42.0
PHP version: 8.1
Database engine: mariadb (11.1.2)