ZF-11678: Zend_Form_Decorator_Errors should allow empty errors

Issue Type: Improvement Created: 2011-08-17T07:57:24.000+0000 Last Updated: 2013-01-22T10:50:53.000+0000 Status: Closed Fix version(s): Reporter: Marc (gore) Assignee: Christian Albrecht (alab) Tags: - Zend_Form

Related issues: Attachments:


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.


<pre class="highlight">

Zend_Form contructs:

<pre class="highlight">
The username is empty

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


<pre class="highlight">

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:

<pre class="highlight">
if (!self::ALLOWEMPTY || empty($errors)) {
    return $content;

That should "fix" it.


Posted by Frank Brückner (frosch) on 2011-08-17T08:43:26.000+0000

{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:

<pre class="highlight">

Posted by Marc (gore) on 2011-08-17T20:50:40.000+0000

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.

Posted by Marc (gore) on 2011-08-17T20:56:01.000+0000

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.

Posted by Frank Brückner (frosch) on 2011-08-18T06:50:54.000+0000


Posted by Marc (gore) on 2011-08-18T07:35:53.000+0000

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.

Posted by Marc (gore) on 2011-08-18T07:37:35.000+0000

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 ;)

Posted by Frank Brückner (frosch) on 2011-08-18T08:02:31.000+0000

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)

Posted by Marc (gore) on 2011-08-18T08:11:08.000+0000

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.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.