Jump to content

addHook() to current field object?


pwFoo
 Share

Recommended Posts

I don't know what exactly you mean by "current" but you can add methods to each class: http://processwire.com/api/hooks/#add_new_method

Maybe you can just use a parameter to determine what should be executed. 

Edit: Thinking a little more about this. What about this.

function myHookFunction($event){
  if($event->object->name !== "YOUR_FIELD") return;
}
  • Like 1
Link to comment
Share on other sites

Hi,

your way should work fine, but I tried to reduce the overhead.

The dynamic function should be added to the current form field object ("$myField", any Inputfield) instead of each instance of a class ("myClass::method").

If there isn't a way I'll do it like you suggested it above.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...