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

Form/Fieldset dependency on FormInterface #35

Open
michalbundyra opened this issue Jan 15, 2020 · 0 comments
Open

Form/Fieldset dependency on FormInterface #35

michalbundyra opened this issue Jan 15, 2020 · 0 comments

Comments

@michalbundyra
Copy link
Member

This issue has been moved from the zendframework repository as part of the bug migration program as outlined here - http://framework.zend.com/blog/2016-04-11-issue-closures.html


Original Issue: https://api.github.com/repos/zendframework/zendframework/issues/7192
User: @claytondaley
Created On: 2015-02-06T16:14:35Z
Updated At: 2015-11-06T21:02:59Z
Body
I'm trying to build an extensible HTML table generator and want to provide HTML table builders a comparable experience -- infrastructure and syntax -- to form construction. Obviously, I don't need a bunch of the form infrastructure (input filters or validation) so I expected to extend Fieldset instead of Form.

As I worked my way through this possibility, I discovered that the type hint for Fieldset->prepareElement() is actually FormInterface per an inheritance from ElementPrepareAwareInterface. Obviously, any class that extends Fieldset will not meet this requirement. I'm trying to find out if this dependency is really obligatory or if you'd consider a BC-incompatible reduction to FieldsetInterface.

In favor of reducing this requirement to FieldsetInterface:

  • FieldsetInterface is the interface that actually extends ElementPrepareAwareInterface
  • FieldsetInterface is inherited by all forms so this would be transparent to most users
  • Unless I missed something, none of the prepareElement implementations in Zend/Form depend on methods in Form but not in the Fieldset.
  • Makes Fieldset usable in isolation. The only other "Form" dependency is the Form/Factory which is really a common factory -- and appears to be so out of convenience not obligation.

In favor of staying at FormInterface:

  • BC break
  • Custom code may require a method from the FormInterface in their PrepareElement calls.
  • Form and Fieldset share a common Factory so they'd still be "coupled". As mentioned above, this appears to be a matter of convenience not coupling.

Comment

User: @claytondaley
Created On: 2015-02-07T23:22:23Z
Updated At: 2015-02-07T23:22:23Z
Body
Incidentally, get/setFormFactory has similar (possibly worse) issues.

  • The factory needs to be available in Fieldset because it supports factory-backed extension to the fieldset.
  • The methods is defined in FromFactoryAwareInterface which is included in FieldsetInterface and used in Fieldset
  • However, the hint for @returns is Form.

Presumably, the right hint is FieldsetInterface. At minimum, a change to FormInterface would be consistent with a previously accepted change -- #3526.

In the long run (maybe ZF3), it'd be better to clean up names (FormFactoryAwareInterface) and split (but extend) the factories so they're easier to inherit.


Comment

User: @claytondaley
Created On: 2015-03-24T18:08:00Z
Updated At: 2015-03-24T18:08:06Z
Body
closed by #7344


Comment

User: @weierophinney
Created On: 2015-03-28T20:34:00Z
Updated At: 2015-03-28T20:34:00Z
Body
Re-opening; reverted #7344 due to the BC breaks it introduces.



Originally posted by @GeeH at zendframework/zend-form#93

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

No branches or pull requests

1 participant