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: Error Messages Not Displayed for Nested Array Fields in Form Inputs #324

Merged
merged 2 commits into from
Dec 7, 2024

Conversation

ryu818
Copy link
Contributor

@ryu818 ryu818 commented Nov 27, 2024

@@ -421,7 +421,7 @@ public function error(string $field): array
$errors = $entity->getError(array_pop($parts));
}

if (!$errors && $entityErrors && !is_array($entity)) {
if (!$errors && $entityErrors) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, we'll need to get some tests added before we can merge this though. This class has some existing tests https://github.com/cakephp/elastic-search/blob/4.x/tests/TestCase/View/Form/DocumentContextTest.php

I'm happy to help if you need a hand.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am unable to set up the test environment, so adding test code is difficult. Could you please assist me with this?

I believe the issue can be reproduced by specifying the following data in new Article and triggering the corresponding error:

{
  "name": {
    "ja": [
      {
        "family_name": "XX",
        "given_name": "XX"
      }
    ],
    "en": [
      {
        "family_name": "XX",
        "given_name": "XXX"
      }
    ]
  }
}

@markstory markstory merged commit f474c62 into cakephp:4.x Dec 7, 2024
2 of 3 checks passed
@markstory
Copy link
Member

Thank you 🎉

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