ZF-11678: Zend_Form_Decorator_Errors should allow empty errors


I tried to decorate my form with a table, like in this Tutorial:

Then I tried to enhance my form with AJAX in JQuery. I find it difficult to pass through the place where JQuery has to put the error messages, if theres no initial "container" with an Id.


Zend_Form contructs:

The username is empty

With JQuery I can select the td with the class error, but only after the form was sent.


I can select it now with JQuery to display an AJAX message and if I set a css width on it I could better handle the layout of the table.

In Zend_Form_Decorator_Errors on line 54 we could do something like:

if (!self::ALLOWEMPTY || empty($errors)) {
    return $content;

That should "fix" it.


{quote}With JQuery I can select the td with the class error, but only after the form was sent.{quote} Sorry, that's completely wrong. Use jQuery:

Maybe you should have read better or I should express myself better ;) But, there is no td the first time, because the error decorator only decorates if there is an error. And if there is nothing, I can´t select it with jquery.

But I see what u did there, but it does not solve the problem. The whole purpose is that u don´t know in JS where the decorator puts the error messages. With your solution you have to know where the JS has to put the error message. If theres a container in the first place which is correctly placed via decorator we could use it and don´t have to worry about placing in js.


No, I don´t know it, because the Decorator can be anything and put the error everywhere. The Problem occurs if I change the decorators, now I have to maintain the code at 2 different places to account for the changes.

In this use case its a table, there will be empty td all the time.

To your other problem, its not a problem, because the standard behavior should be to not show the empty tag. But if u need it, you should be able to change that. And I for myself have a valid use case where I need it. Imagine a generated form with dozens of input, the form generates all your stuff, but the JS u have to change for every input if u change something at the decorator.

Maybe I should mention that I build a custom formText view helper for that purpose which extends ZendX_JQuery_View_Helper_UiWidget.

Forgot to say that I have to manually change that behavior and then I´m sure that I don´t do anything fancy to show some red boxes ;)

My suggestion: write a error decorator for ZendX_JQuery which adds the JavaScript automatically.

By the way: Forms are not tabular data! (We no longer have 1997)

Maybe you should tell Matthew that, because he did that in the tutorial above ;)

And the JQuery should be part of the form element, as in every element in the ZendX.