Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RyanThompson/d009c024853781f47c03 to your computer and use it in GitHub Desktop.
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.
<?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