<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[
<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[
Zend\Form\Decorator\JsAutoValidator is a unobtrusive JavaScript validator that takes into account every (javascript) possible validator rule, and writes down a json with all the information, making available all you need to know to make your own javascript validation. Zend\Form\Decorator\JsAutoValidator will generate an agnostic json for element validation, filtering and error decoration. This will allow you to use the built in javascript validator or your own implementation with a simple adapter pattern.
Zend Framework: Zend\Form\Decorator\JavascriptValidator Component Proposal
Proposed Component Name
Zend\Form\Decorator\JavascriptValidator
Developer Notes
http://framework.zend.com/wiki/display/ZFDEV/Zend\Form\Decorator\JavascriptValidator
Proposers
Ricardo Buquet
Zend Liaison
TBD
Revision
1.0 - 1 March 2012: Initial Draft. (wiki revision: 15)
Table of Contents
1. Overview
It also has a built in javascript validator, which can be replaced by your own implementation.2. References
3. Component Requirements, Constraints, and Acceptance Criteria
4. Dependencies on Other Framework Components
5. Theory of Operation
The component is added to any Zend_Form
6. Milestones / Tasks
- Milestone 1: [DONE] design notes will be published here
- Milestone 2: [DONE] Working prototype checked attached to the proposal (I don't know how to publish into the incubator) supporting use cases #1, #2
- Milestone 3: [DONE] Unit tests exist, covering 100% of the code.
- Milestone 4: [DONE] Initial documentation exists.
7. Class Index
- Zend_Form_Decorator_JsAutoValidation
8. Use Cases
| UC-01 | Assign decorator through ini file |
|---|
| UC-02 | Or using a php file. |
|---|
And in both UC something like this will be printed in json through the inlineScript view helper.
9. Class Skeletons
This is the class skeletons
5 Comments
comments.show.hideMar 04, 2012
Ricardo Buquet
<p>I have added an attachment with a fully working super simple use case for the decorator.<br />
This example contains the JavascriptValidator.php decorator file, the JavascriptValidator.js companion file and a simple use case.</p>
Mar 08, 2012
Frank Brückner
<p>Hi Ricardo,<br />
there are two problems with this proposal:</p>
<p>1. If this decorator should be implemented in ZF1 then there is not much time, because:</p>
<blockquote>
<p>The plan is for all new code, unit tests and documentation to be ready by 23rd March 2012, peer reviewed by a member of the CR Team and committed to the Subversion repository.</p></blockquote>
<p><a class="external-link" href="http://zend-framework-community.634137.n4.nabble.com/ZF-1-12-Release-td4425960.html">http://zend-framework-community.634137.n4.nabble.com/ZF-1-12-Release-td4425960.html</a></p>
<p>2. And in version 2, the decorators may be removed: <a class="external-link" href="http://framework.zend.com/wiki/display/ZFDEV2/RFC+-+Forms">http://framework.zend.com/wiki/display/ZFDEV2/RFC+-+Forms</a></p>
Mar 08, 2012
Ricardo Buquet
<p>Hi Frank!<br />
Well that's a shame!!!, it's working very nice.<br />
Maybe when it's defined if ZF2 if it will use decorators or not I could refactor what ever is needed. Anyway this decorator doesnt really need to be a decorator, it could be anything that have access to the form and form elements and their respective validation rules, originally I wrote this code as a Class extending Zend_Form, and then move it to a decorator. Cause I thought that was a better approach.</p>
Mar 08, 2012
Wil Moore III (wilmoore)
<p>It's a good idea...here are a few of my thoughts:</p>
<ol>
<li>would be nicer as a service class that accepts a form validator chain (see ZF2 form proposal)</li>
<li>add a view helper that consumes the service</li>
<li>provide hooks to existing form validators such as: <a class="external-link" href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/">http://bassistance.de/jquery-plugins/jquery-plugin-validation/</a> (i.e. do not provide a ZF specific implementation)</li>
<li>documentation on how to build your own hooks to your custom JS validator</li>
<li>documentation on how to plug it into HTML5 native elements</li>
</ol>
Mar 09, 2012
Ricardo Buquet
<p>Hi Wil thanks for your comments,</p>
<p>I really like to make this code better<br />
1- I will take a look into the proposal that you are suggesting.<br />
2- Can you give me a hint? I really didn't get you<br />
3- The hooks parts... I think that if my code can expose all the validation parameters in a json format. It will be very simple to create an adapter pattern for any kind of javascript/library validation. Don't you think?<br />
4- I started that this afternoon.<br />
5- mmmm I really didn't think of that, that would be an great feature.</p>
<p>Beside that<br />
I also don't know where should I place the javascript file that comes with this decorator. I have created an alias in my virtualhost for the javascript which now i'm placing it inside my php, pointing to my public javascript folder.<br />
Any suggestion?</p>