The event handler must be a valid PHP callback. The following are
some examples:
function ($event) { ... } // anonymous function
[$object, 'handleClick'] // $object->handleClick()
['Page', 'handleClick'] // Page::handleClick()
'handleClick' // global function handleClick()
The event handler must be defined with the following signature,
function ($event)
where $event is an Event object which includes parameters associated with the event.
public on ( string $name, callable $handler, mixed $data = null, boolean $append = true ) | ||
$name | string | the event name |
$handler | callable | the event handler |
$data | mixed | the data to be passed to the event handler when the event is triggered. When the event handler is invoked, this data can be accessed via [[Event::data]]. |
$append | boolean | whether to append new event handler to the end of the existing handler list. If false, the new handler will be inserted at the beginning of the existing handler list. |