Created
March 15, 2012 09:10
-
-
Save frosas/2043106 to your computer and use it in GitHub Desktop.
Example of defining and calling PHP closures anywhere
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ... | |
$formBuilder->add('user', 'choice', array( | |
'choices' => call_user_func(function() use ($users) { | |
$choices = array(); | |
foreach ($users as $user) $choices[$user->id] = $user->name; | |
return $choices; | |
}) | |
)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment