pclib  2.3.2
Lightweight PHP framework
PClib callback functions

You can override default element print/validate handler for any element (tag) in template. PClib supports two events when your handlers can be called:

You must set your handler in elements section of the template, like this:

string NAME onprint "printName"

or

input NAME onvalidate "validateName"

for validation.

Next, you must define your handler in php source code. Note that handler can be any php callable.

function printName($sender, $id, $sub, $value) {...}

With print handler you can modify result printed into template, or perform some additional actions. Example:

function printName($sender, $id, $sub, $value)
{
print "Your name is <b>$value</b>";
}
function validateName($sender, $id, $sub, $value)
{
if (!in_array($value, array('Steve','Bill','Linus')))
return "This name is not allowed!"
else
return '';
}

Since php 5.3.0 you can use even anonymous functions as handler:

$form->_NAME->onprint = function($sender, $id, $sub, $value) {...}