Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix removing to much when creating a dotted attribute key #16

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gisostallenberg
Copy link
Contributor

When having a JSON structure with nested data with a key ending (or being the same as the parent property to much is removed from the attribute when it is converted into a dotted key.

Example:

{
  "settings": {
    "personal_settings": {
      "darkmode": true
    }
}

Without this fix a call to getDottedAttributeKey will give the attribute personal_darkmode instead of the expected personal_settings.darkmode.

When having a JSON structure with nested data with a key ending (or being the same as the parent property to much is removed from the attribute when it is converted into a dotted key.
Example:
```json
{
  "settings": {
    "personal_settings": {
      "darkmode": true
    }
}
```

Without this fix a call to `getDottedAttributeKey` will give the attribute `personal_darkmode` instead of the expected `personal_settings.darkmode`.
@Naoray
Copy link
Owner

Naoray commented Aug 3, 2023

@gisostallenberg, can you please post the code which defines the nested JSON field?

@gisostallenberg
Copy link
Contributor Author

Because the issue occurs in a private project the initial example is made up.
The fields are generated from some nested classes, so I'm not 100% sure if the code below is accurate, but I think so.

JSON::make('settings', [
   JSON::make('personal_settings', [
       Boolean::make('darkmode', 'darkmode'),
   ])
])

@Naoray
Copy link
Owner

Naoray commented Aug 4, 2023

Is there some other fields or panel defined which wraps around the JSON definition?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants