In general, it works in the same way as the previous step. In case if you have:
namespace Acme\DemoBundle\Entity;
use Symfony\Component\Validator\Constraints as Assert;
class User
{
/**
* @Assert\Choice(callback = {"Acme\DemoBundle\Entity\Util", "getGenders"})
*/
protected $gender;
}
namespace Acme\DemoBundle\Entity;
class Util
{
public static function getGenders()
{
return array('male', 'female');
}
}
Then:
$('form#user').jsFormValidator({
callbacks: {
'Acme\\DemoBundle\\Entity\\Util': {
'getGenders': function() {
return ['male', 'female'];
}
}
}
});
Pure Javascript:
var field = document.getElementById('user');
FpJsFormValidator.customize(field, {
callbacks: {
'Acme\\DemoBundle\\Entity\\Util': {
'getGenders': function() {
return ['male', 'female'];
}
}
}
});
also, you can simplify it as it was described here