36 Responses

  1. Radu
    Radu at | | Reply

    How long till you will be a ZCE on Zend Framework? :D

  2. Siderite
    Siderite at | | Reply

    Why not change the display to inline for all DDs? Some XHTML rule?

  3. Siderite
    Siderite at | | Reply

    Yummy! realmendontneednospacebars

  4. Radu
    Radu at | | Reply

    True men don’t kill coyotes!

  5. Serban
    Serban at | | Reply

    Great quality post! Thanks!

  6. seddass
    seddass at | | Reply

    Very interesting article.
    Is there a way to set “hidden” class to dt element instead of setting label class “hidden”. I mean that DT is still visible and creates unnecessary space in the design.

    See the code that is generated with yours helper:
     

  7. Jack Tanner
    Jack Tanner at | | Reply

    One alternative is this:

    Note that you can’t stack those two, because they return a boolean, not the object itself.

  8. Jack Tanner
    Jack Tanner at | | Reply

    Tudor: yes, you’re right, that would produce invalid HTML. But it’s also possible to remove the dl/dt/dd nonsense from the form and non-hidden form elements, leaving clean, simple, and valid HTML.

  9. Joe Devon
    Joe Devon at | | Reply

    Yes, this hard to remove extra markup in the wrong places and inability to place good markup where you want when you want is making me batty.

    The rest works fine but the decorators seem kludgy to me.

    And I’d love if the docs that showed examples made sure to include the config file w/ each one. By sticking this stuff in a config file, you can reuse validators/filters in your javascript.

  10. Colin
    Colin at | | Reply

    Try changing the default element decorators. There is a good post about this on the dev zone, http://devzone.zend.com/article/3450.

  11. Jack Tanner
    Jack Tanner at | | Reply

    By the way, I recently came across this bug in ZF where it generates invalid form labels (in its default config).

    http://framework.zend.com/issues/browse/ZF-6426

  12. Mike Gerwitz
    Mike Gerwitz at | | Reply

    (Apparently it replaced & n b s p ; with space in my above reply.)

  13. Mike Gerwitz
    Mike Gerwitz at | | Reply

    Zend escapes the label, so it outputs ” ” in the actual HTML. Rather than toying with the escape function, I just used the following workaround:

    (Assuming that $decorators is the result of $element->getDecorators()).

  14. Andy
    Andy at | | Reply

    This is much easier to really hide the hidden field: Simply delete the Decorators of the element:

    $hiddenElement->setDecorators(array());

  15. Slam
    Slam at | | Reply

    Fixing this problem with a View Helper is a waste of time imho.

    I created a mother class (that extends Zend_From) for all my forms, and rewritten render() function:

    So no different code is written in forms or views.
    You can use even Tudor solution with my implementation.

    P.S.: Tudor, make possible and easily visibile for all how to <code> comment code plz.

  16. Slam
    Slam at | | Reply

    Forms are not properly in one letter of the MVC acronym, forms are forms, in fact in a form you manage the Model/Control of a form (validators, ‘required’ etc) and also the View (decorators, label, etc), so i think that is right and legitimate to manipulate all form properties directly in form classes.

    Moreover, that implementation skimp lines of code and new classes creation with the same results and no different business logic nor logic error.

    Btw, this is my interpretation.

  17. Exception e
    Exception e at | | Reply

    @Tudor Your last solution will still generate dt’s without a class. At best it will add a class to the inside the .

    Could you confirm this, or did you prepare your elements in a special way (changing the decorators etc).

  18. Exception e
    Exception e at | | Reply
  19. Iacovos Constantinou
    Iacovos Constantinou at | | Reply

    You should use ViewHelper and HtmlTag decorators in order to achieve this. The following piece of code will completely ignore the label tag (incl. the dl) and it will generate both the dd and input tags.

  20. Exception e
    Exception e at | | Reply

    @Iacovos Constantinou Thank you!

  21. LC
    LC at | | Reply

    I use …

    … stacked and it works, for hidden and hash elements.

    I don’t care if it does not validate.

  22. Croma
    Croma at | | Reply

    Really helpful info.

    I too like to get my pages validated.

    Thanks

  23. Jurian Sluiman
    Jurian Sluiman at | | Reply

    I found another way to change the html tag into one with a class=”hidden”. In your method you loop through all elements, which can cost a lot when you use large forms. Also with subforms the method doesn’t really work well.

    I override the loadDefaultDecorators for the Zend_Form_Element_Hidden which gives the opportunity to add the class directly when the hidden elements are added (and not only when rendered).

    Because it’s too long to post the whole story, here’s just the link to my blog post:
    http://juriansluiman.nl/en/blog/article/106/hide-hidden-zend_form-elements

  24. Lizozom
    Lizozom at | | Reply

    Thank you!
    Very helpful!

  25. kwiaty przez internet
    kwiaty przez internet at | | Reply

    Fantastic job dude. Cool.

  26. Adolfo
    Adolfo at | | Reply

    nice one, thanks!

  27. Atef
    Atef at | | Reply

    i force the hidden value of the checked input to 1 :

Leave a Reply