Block editor not showing saved content.
In my app i have a product model with the HasBlocks trait and a product repository with the HandleBlocks trait. For some reason the blockeditor is always empty when i visit it. but the data for it is present in the database. am i forgetting a step ?
11 Replies
Hi @kwatman what version of twill is this happening? and would you be able to share a reproduction?
Im using twill 3.3.1. cant share all of the code of the project as its is confidential. But i have by now some more information that i found while trying to debug this. i dumped the fields that get loaded in the repository and it looks like this:
notice that blocks is null. i also dumped the afterSave fields an they look like this:
here blocks is filled in.
i also found 2 queries in the laravel debugger to twill_blocks. I tried debuggin these queries to see what they return.
when running
select * from twill_blocks
I get all the blocks.
But when running
select * from twill_blocks where twill_blocks.blockable_type = 'App\Models\Product'
it does not return anything.
im sorry that i cant share anything reproducible but i hope you can help me further with this info.dont know what i did but now the blocks are loaded in the getFormFields dump in the repository. however they still dont show in the editor
Okay, it's hard to figure out the problem without a reproduction but let's see if the blocks are getting to the frontend. Can you tell me the value of
TWILL.STORE.form.blocks
in your browser console?this is what it shows. clicked some of the values open. any value in particular you need to see ?
Yeah, the blocks are not getting to the FE. You should have the default editor values in the result
So if undersatnd it correctly then the blocks get passed to the page but it does not laod them in the javascript object. is there somthing that happens between these steps ? i was not to original developer of this project so maybe the original developer hooked into a step that happens during the loading of the page and does something there that fucks it up? is that possible in twill ?
after checking i see that this happens everywhere on the site where a block editor is used. not just with the product model i made
The blocks might not have been passed, what you can do is get into the edit method in the ModuleController and dump
$this->form($id)
. Then check the form_fields
to see the value of blocks
.blocks has values in the dump.
Then, somehow, the blocks are not passed to the frontend. I would suggest you reinstall twill or check out the render method of
vendor/area17/twill/src/View/Components/Fields/BlockEditor.php
and the _block_editor view file. I can't reproduce this issuei found it. i checked the _block_editor.blade.php file and it looked like this:
looking in the twill source code i could see that the last aprt needed to be:
change it back to that fixed the issue. looks like the dev before me made some changes to the file.
thanks for all the help @zeezo887 .