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

Uniform Hooks #261

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Uniform Hooks #261

wants to merge 2 commits into from

Conversation

adamkiss
Copy link
Contributor

This is a work in progress of allowing to call hooks on various events; So far, I've added the hooks, and events of "error", "success" and "always", called in the done() function.

There are no tests yet, but I will add them if/when we iron out naming/existence of this feature and its parts.

@adamkiss adamkiss mentioned this pull request Mar 16, 2024
@mzur
Copy link
Owner

mzur commented May 1, 2024

Thanks and sorry for being silent for so long! I think this looks good, as it solves your use case from #238. But I don't see a need for the always hook. Couldn't this just be called next to the form execution?

@adamkiss
Copy link
Contributor Author

adamkiss commented May 2, 2024

@mzur No problem at all! This is open source after all! (and uniform isn't the only plugin I'm using patched from a custom repo 🦅 )


Since I based the naming originally on github, I just included the always hook as well. But looking at the order of execution now, if you have a standard "flash/redirect" form and a code like this:

$uniform = $uniform->guard()->guard()->action()->done();
doCustomStuff($uniform);

the doCustomStuff never gets called, because done() redirects the page at that point.

->on('always') on the other hand gets called (You also create a compact form definition code block, but that in itself prob wouldn't be a sufficient argument)

@adamkiss
Copy link
Contributor Author

adamkiss commented May 2, 2024

Update: interestingly, if you don't add the ->done() call (manually), the hooks don't get called in case of success, but the form works (and the doCustomStuff() gets called)

I don't know what to make of it.

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