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

Show the correct tab for subfield errors #5690

Merged
merged 2 commits into from
Oct 14, 2024

Conversation

krjohnston
Copy link
Contributor

WHY

To correctly detect the crud fieldName for subfields with validation errors and display the relevant tab to maintain consistency with the behaviour of other fields that have validation errors.

BEFORE - What was wrong? What was happening before this PR?

When the first error is on a subfield, I expect that tab to be the active tab as it would be with other fields.
Because the fieldname is in dot notation array format, this does not match the crud fieldname e.g. someRelation.0.name does not match the fieldName someRelation, therefore the error is skipped when determining the tab to activate

AFTER - What is happening after this PR?

The crud fieldName is parsed from the current field under test and will match the parent fieldName, allowing it to set the active tab appropriately.

HOW

How did you achieve that, in technical terms?

I stripped the crud fieldName from the start of the subfield name
$fieldName = preg_split('/\.\d+\./',$fieldName)[0];

Is it a breaking change?

No

How can we test the before & after?

Create a validation error on a subfield that is not on the first tab.
Before: the errors are shown, but the subfield's tab is not active.
After: The tab with the subfield is the active tab.

Copy link

welcome bot commented Oct 14, 2024

BOOM! Your first PR with us, thank you so much! Someone will take a look at it shortly.

Please keep in mind that:

  • if this constitutes a breaking change, it might take quite a while for this to get merged; we try to emulate the Laravel release cycle as much as possible, so developers can upgrade both software once; this means a new big release every ~6 months;
  • even if it's a non-breaking change, it might take a few days/weeks for the PR to get merged; unless it's a no-brainer, we like to have some community feedback on new features, before we merge them; this leads to higher-quality code, in the end; we learnt this the hard way :-)
  • not all PRs get merged; sometimes we just have to hold out new features, to keep the packages lean; sometimes we don't include features that only apply to niche use cases;
  • we're not perfect; if you think we're wrong, call us out on it; but in a kind way :-) we all make mistakes, best we learn from them and build better software together;

Thank you!

--
Justin Case
The Backpack Robot

@pxpm pxpm merged commit 8a06a85 into Laravel-Backpack:main Oct 14, 2024
2 checks passed
Copy link

welcome bot commented Oct 14, 2024

WHOOP-WHOOP! Congrats, your first PR on this repo has officially been merged.

party

You should also receive an email inviting you to the Community Members team. That's where we, committed community members, debate new features and decide what's in the Backpack roadmap. Feel free to ignore the invitation if you're not interested :-)

If you want to help out the community in other ways, you can:

  • give your opinion on other GitHub Issues & PRs;
  • chat with others in the Gitter Chatroom (usually for quick help: How do I do X);
  • answer Backpack questions on Stackoverflow; you get points, people get help; you can subscribe to the backpack-for-laravel tag by adding a new filter; that will send you emails when new questions come up with our tag;

Again. Thank you for the PR. You are a wonderful person. Keep 'em coming :-)
Cheers!

--
Justin Case
The Backpack Robot

@pxpm
Copy link
Contributor

pxpm commented Oct 14, 2024

Thank you @krjohnston 🙏

Much appreciated. Will tag a new version later today with the changes!

Cheers

@krjohnston
Copy link
Contributor Author

Thanks @pxpm

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