Using table field as subfield #756
-
Im using a table field inside a relationship as a subfield. When the table is stored in the json field in mysql the value is escaped. When i use the table field as a normal field the value is not escaped. It gives me some issues as Laravel cant cast the escaped string as array (as defined in my model). The biggest issue is that the same field in the database will work differently when i save it as as a subfield and when using it as a regular field. Anyone seen this issue and is there any options that could be used in the subfield ? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Hello @lieto-dk thanks for the question. I've never faced it, I don't recall using a table inside a repeatable. Can you provide more details so that I can try to reproduce the issue ? What kind of relationship is it ? What's the real problem ? Is that it stores it as a json array instead of a json string or the other way around ? Can you also tell me your backpack version with Please provide as many details as you can so that I can easily reproduce your issue and try to help you. Cheers |
Beta Was this translation helpful? Give feedback.
-
Hi, Hope you can direct me in the right direction to solve this puzzle ! I use the following PHP VERSION:PHP 8.1.13 (cli) (built: Nov 26 2022 14:07:36) (NTS) LARAVEL VERSION:10.32.1.0 BACKPACK PACKAGE VERSIONS:backpack/basset: 1.2.1 |
Beta Was this translation helpful? Give feedback.
Hey @lieto-dk sorry it took me some time to get back here.
As you already found out the problem is related with a double encoding. That happens because the table already sends the encoded information, and when your "model cast" for the repeatable container runs it double encodes the table field.
A quick solution I can think of is to to "decode" the table fields in the repeatable container before the create/update processes, something like: