Created
July 6, 2015 23:51
-
-
Save RyanThompson/d009c024853781f47c03 to your computer and use it in GitHub Desktop.
Here is an example of a property handler using a closure that will later be evaluated.
This file contains 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 namespace Acme\Foo\Form; | |
class FooFormFields | |
{ | |
/** | |
* Handle the form fields. | |
*/ | |
public function handle(FooFormBuilder $builder) | |
{ | |
$builder->setFields( | |
[ | |
'name', | |
[ | |
'field' => 'phone', | |
'disabled' => function() use ($builder) { | |
return $builder->getMode() === 'edit'; // Disable the input for edit forms. | |
} | |
] | |
] | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment