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 Simplification and Upgrade [potential BC] #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

claytondaley
Copy link

NOTE: This PR requires ZfcUser PR #562 and ZfcUser PR #564

NOTE: This PR may break backwards compatibility because it defaults to underscore notation for form fields. This could be changed by supporting a flag on the hydrator, but we won't necessarily know the right defaults for all users.

This patch now rewrites significant parts of ZfcUserAdmin:

  • Closures are replaced by factories for performance reasons (see section 3 in top answer)
  • Forms now use the bind() pattern. This covers all changes in PR Binding User to Edit Form fixes issues #30 and #31 #50 except that the hydrator is created in __construct so it is available to extend during the 'init' event.
  • Forms now provide an enhanced Validation Group strategy. A modest improvement on Rob Allen's recommendation, elements can be individually excluded using an attribute/option. This enhances extensibility.
  • At some point, I expect the Hydrator initialization and Validation Group changes to be migrated to ZfcUser's forms, but this will provide the capability to 1.x users during the transition.

This eliminated the need for lots of support infrastructure in these classes. As a side-effect, the new code supports a broader set of Zend Form features.

P.S. Due to the increased size of this change -- and the simplicity and power of the form change --, I moved it to a separate PR.

…in top answer at http://stackoverflow.com/questions/14667621/zf2-optimize-for-high-traffic)

 - CreateForm and EditForm add hydrator (per ZfcUser settings) in `__construct`.  This makes it available to extend during the form `init` event.
 - Converted EditForm to inherit directly from Base rather than indirectly through Register (requires ZfcUser PR)
 - Converted EditForm to store data using `$form->bind($object)` pattern often used in Zend Forms (requires ZfcUser PR to avoid sending password to browser)
 - Forms now use an enhanced Validation Group logic.  Elements are selectively excluded based on specific options or attributes.  This significantly improves extensibility.
 - Cleaned out old helper code
 - Now repopulates disabled fields (side-effect)
@stijnhau
Copy link

Any progress on this?

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

Successfully merging this pull request may close these issues.

2 participants