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: Handle Empty State for KeyValueEntry #11129

Conversation

jafar-albadarneh
Copy link
Contributor

@jafar-albadarneh jafar-albadarneh commented Jan 28, 2024

Description

Currently, KeyValueEntry handles empty arrays [] as null state very well.
The case happens when the model attribute is optional and its value is an empty array [].
More about the issue is described here

  • [ * ] Visual changes (if any) are shown using screenshots/recordings of before and after.

Before
image

After
image

Code style

  • composer cs command has been run.

Testing

  • Changes have been tested.

Documentation

  • Documentation is up-to-date.

- Make sure to cast `null` to `[]`
- Update `key-value-entry.blade` to check for the empty state and render an empty state label
- Expose new method `emptyLabel()` to customize the placeholder text
- Add necessary defaults for `emptyLabel` attribute
- Update Docs
@jafar-albadarneh jafar-albadarneh changed the title feat: Handle Empty State for KeyValueEntry fix: Handle Empty State for KeyValueEntry Jan 28, 2024
- default to empty collection instead of `[]` for consistency
@danharrin danharrin added the enhancement New feature or request label Jan 29, 2024
@danharrin danharrin added this to the v3 milestone Jan 29, 2024
@danharrin danharrin linked an issue Jan 29, 2024 that may be closed by this pull request
- remove state override method
- handle `null` state override from within the template
- update docs
- update i18 refs
@danharrin danharrin merged commit 92bd475 into filamentphp:3.x Jan 29, 2024
6 checks passed
@danharrin
Copy link
Member

Thank you for picking up on our code style and structure, and trying to make this fit into the rest of the framework as well as possible. It is appreciated!

@danharrin
Copy link
Member

Realised this is actually just placeholder() like the other entries, so renamed to that

@jafar-albadarneh
Copy link
Contributor Author

Makes complete sense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Infolist KeyValueEntry handles state with value empty array as NULL
2 participants