What's the easiest way to pass a variable to a form in zend framework 2?
It seems you can only send a name value to the contructor, but i need to send a few options to the form to set/fill some selectors.
Thanks!
What's the easiest way to pass a variable to a form in zend framework 2?
It seems you can only send a name value to the contructor, but i need to send a few options to the form to set/fill some selectors.
Thanks!
If you extend Form with your own class:
You can then pass in any variables you like via it's constructor and pass the form name to the parent Form class as such:
You might also want to consider using a
Factory
to inject your dependencies which can be configured for example in yourModule.php
:This form is now available via the service locator from any service aware class:
With the dependencies injected via the factory.