• Iulian Ilea

    Nice trick!

    But you shouldn’t reset the stack of the view script paths. I think it’s more appropriate to use addScriptPath() because after you render the form you may need to render other partials which you know are placed in the view’s script path but you have no idea that the script path has been changed.

  • I meant the view object, not viewRenderer which is just a proxy for obtaining the real view object.

  • Iulian Ilea> yes, you’re right 😛 I’ve edited the post!

    Ionut> I like it this way…I think it improves readability!

  • Pretty nice Tudor. This is basically the easiest way to achieve maximum flexibility with Zend_Form, although I don’t like this ZF component a lot. And there’s a little thing I would change in your implementation. In MyForm::__toString(), I would replace:

    with…

    Zend_Form has a getter/setter pair for the viewRenderer object which is helpful if the need arises to inject the the form with a custom viewRenderer. Static calls suck big times.

  • Pingback: Help me understand this almost-working HTML Zend Form - Zend Framework Forum()

  • melkorm

    $translator = Zend_Registry::get(‘translator’);

    Why are You using it manually? If the registry key of translator is set to “Zend_Translate” then labels & stuff is automatically translated 🙂 Even in navigators etc.

  • Yes, I know! But this article was published more than an year ago and then I was just learning to use Zend Framework.

  • Weed@t

    Hello, many thanks to you !!!

    I’ve spent two days to search a solution to style free on my forms with Zend (I’m zend beginner) and your solution is so cool !

    So simple, as I love…

  • joseph

    I almost jumped when i saw this page.I must admit this is the ever first complete tutorial on how to use viewscript in Zend.But i was so sad cause i can’t figure out how other people got it working.

    i removed the translator bit, and used $this->getView().
    i got:” Example_Form_Myform::__toString() must not throw an exception.”
    So here is my project structure

    Any suggestion is welcomed.i really need this stuff.thanks

  • joseph

    wow i used indentation to do the project structure how come it got so messed up? how can i edit this?

  • Put the file in
    /library/Project/View/Helper/SplitElement.php
    and the class’ name should be Project_View_Helper_SplitElement. Then, you need to add to following lines to your bootstrap:

  • joseph

    Thanks man will try it out when i got home.But really nice work 😉

  • Farhad

    Hi,

    The tutorial is great and I finally got my styling finished, however the submit button isn’t working.

    I also checked the source code and I don’t see the form tags. Do you know what I did wrong?

    Thanks!

  • Martin

    How can I render captcha ?? It wouldn’t work if I said echo $captcha[‘body’] …. any ideas??

  • Robert Sharp

    Thanks for the tutorial. I was having such a tough time trying to get it to work. It helped me out a lot. thanks.

Advertisment ad adsense adlogger