Closed robertmarney closed 1 month ago
@Tarpsvo - I wanted to check in and see if this is something that will be considered. Thanks!
@robertmarney Hey!
Pulled the latest release with this commit included and ran into an issue.
Namely when in database, translatable json column value is as such {"en": ""}
, the Text field will throw the following error.
exception: "ErrorException"
file:"/vendor/outl1ne/nova-translatable/src/TranslatableFieldMixin.php"
line: 80
message: "foreach() argument must be of type array|object, string given"
The field is the most basic.
Text::make('My Column')
->translatable(),
The first image shows dd($value) when database has {"en": ""}
The second image shows dd($value) when database has {"en": "abc"}
I'd say that the issue relies somewhere else, but you just happened to stumble upon it 😅
Fixed via #133
We ran into an issue where nova-translatable was casting user provided string
0
to float before it was serialized to send to the front end.Unlike PHP, JS (Vue that renders) considers float 0 as falsy and is not rendering in some fields. How this was manifesting is user was providing a
0
value within the text field and it would save, upon view / edit the field would be presented as empty.Proposed change would cast values within a
Text
field (but notNumber
asNumber
extendsText
) to a string which I think is logical as a translation of a text field should be considered a string type.