[4.1][Bug] Table field is not properly (?) formatting JSON
See original GitHub issueBug report
What I did
Using the table field, then adding data to a field that contained a quote.
What I expected to happen
The data to be saved or remembered.
What happened
The JSON isn’t valid.
What I’ve already tried to fix it
Problem seems to lie in table.blade.php
on line 208 where you’re formatting the inputs for JSON, but I’m not sure exactly the solution, or why this is invalid…
This problem exists on your demo site so let me show you there.
Edit any Monster
and go to Miscellaneous and add a row to the table.
Do one without any quotes and save - it works:
Then add a new row with a quote:
Now when you save and go back - the data is gone. It’s invalid JSON so is presumably filtered somewhere on your model. For me I have a validator for this JSON and it complains.
The other way this can manifest is with form value persistence. E.g. add a row without a quote and refresh the page - it will still be there. And likewise add a row with a quote and it will not be there on refresh.
Instead you get this error in the console:
I honestly don’t know why this seems to happen - the resouces online I’ve looked at seem to suggest you’re escaping the quotes correctly!
Cheers all
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (5 by maintainers)
Top GitHub Comments
I’ve just merged #2960 that fixes this. It’ll be available with a
composer update
later today when we tag version 4.1.12. Thanks a lot @bnxdev for raising the issue and @pxpm & @ibpavlov for fixing it! I’m sorry it took so long to fix and merge.Great! Then can you please create a PR for this @pxpm ? I see @bnxdev hasn’t replied in 21 days so he’s probably busy.