-
Notifications
You must be signed in to change notification settings - Fork 295
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
Better field rules collection, with AfterCollectingFieldRules event #491
Better field rules collection, with AfterCollectingFieldRules event #491
Conversation
I'm not a fan of |
@rudiedirkx looks good. Would maybe implementing ArrayAccess for Rules solve the backward compatibity issue? |
Only for very simple access like Maybe add some kind of deprecation notice where it encounters an |
Another use for this new event is #402. A developer can add an |
Ok, let's leave it like this. Thanks for PR. |
This is pretty bad code... I blame you too Kris! To add a single
I have to explicitly add the Slight more readable:
but still way too explicit. So I'm adding a few helper methods to
And I should beta test more next time, before PR'ing. |
Huh...
I can't push to master? How do I make changes? I thought the Collaborator point was to not need PRs for everything..? I've pushed to a separate branch: https://github.com/kristijanhusak/laravel-form-builder/pull/new/better-rules-collection-methods |
@rudiedirkx try again, i removed restriction. |
Maybe that was on purpose. I don't know your desired flow. Push worked!, and I removed the temp branch. I'll still make PRs for significant features, but this seemed small enough. Agree? Disagree? @mikeerickson too? |
@rudiedirkx I was going to approve this PR when I got home, but it has already been done. |
Yes, this PR is approved a while ago. But it was incomplete, so I wanted to complete the feature separately, without PR, quickly. I don't know what the best flow is for a multi dev project. Every commit can't be a PR. But sometimes a review is a good thing. |
@rudiedirkx Well, if we need to have a second set of eyes, just perform the typical PR request a PR review? Am i missing something? |
@rudiedirkx @mikeerickson lets always create PRs and have someone review it. |
Sounds good to me, I actually like it this way better. I like the workflow that requires peer code review, if for anything to catch even little issues. |
My apps have custom fields and custom validators, but I want to use the form builder as pure as possible. An event for altering field rules would be perfect. Event
BeforeFormValidation
is too late, because it has prepared the entire validator already.Patch is almost completely backward compatible, but not quite. The return type of
FormField::getValidationRules()
has changed fromarray
toRules
. For new fields that's fine (becauseRules::fromArray
), but if a developer extends an existing field and expects an array fromparent::getValidationRules()
, that will crash.