Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.16.0 removes FormElementManager::get() #92

Closed
rieschl opened this issue Mar 21, 2021 · 1 comment
Closed

2.16.0 removes FormElementManager::get() #92

rieschl opened this issue Mar 21, 2021 · 1 comment
Labels
Milestone

Comments

@rieschl
Copy link
Contributor

rieschl commented Mar 21, 2021

BC Break Report

Q A
Version 2.16.0

Summary

When refactoring the FormElementManager class in #75 and removing support for service-manager v2 the V3Polyfill and FormElementManagerTrait were copied together to a "real" FormElementManager class.
But it seems that the previous method \Laminas\Form\FormElementManager\FormElementManagerTrait::get wasn't copied.
The main purpose of that method was calling \Laminas\Form\FormElementManager::setInvokableClass() for invokable Forms to override the default InovkableFactory with \Laminas\Form\ElementFactory.

Previous behavior

Invokable Forms (and probably all other Elements and Fieldsets) were created with the \Laminas\Form\ElementFactory.

Current behavior

Invokable Forms with options are instantiated incorrectly, because \Laminas\ServiceManager\Factory\InvokableFactory instantiates the object differently.

How to reproduce

Fetch a Form with options from the FormElementManager

$this->formElementManager->get(Form::class, ['foo' => 'bar']);

Previously, when no custom factory was registered, FormElementManagerTrait::get called FormElementManager::setInvokableClass to use ElementFactory, which creates the object with return new $requestedName($name, $options);. Now, this is missing, causing InvokableFactory to instantiate the class with new $requestedName($options), using the options array as form name.
The default constructor for Fieldset which Form extends from, is public function __construct($name = null, $options = []).
The options array is used as form name and later on, when rendering the form, the escaper view helper throws up when trying to escape the name atrribute of the form opening tag because it's an array and not a string.

@Slamdunk
Copy link
Contributor

Fixed by #93

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants