We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Form Decorators

Hi community,

What do you think about added form decorators to Phalcon? It will be somethink really useful. I have started somethink here:


The idea is very easy : in view you can make somethink like this $form->toHtml();

This will be helpful to some users I'm sure, but the whole idea of the current phalcon form structure follows MVC design (in my opinion). Developers do all the code work and the web designers format the page which is why each element has to be generated one by one otherwise wheere's the flexibility to the designers?

edited Aug '14

So if you agree with me that this decorators can be helpful to some users why did you delete my post? Webdevelopers can put form in some div wrapper with css id and they can style all neccessery think using "#idFormWrapper form ..." - it's not complicated. Obviously some project required unusual styling or location - in this case webdevelopers can create form with all form elements, labels errors etc. In my opinion less is better that more. It will be much quicker to make something like this:

<div id="loginForm">
{{ form.toHtml() }}


<div id="loginForm">
     <form method="{{ form.getUserOption('method') }}" action="{{ 
form.getUserOption('action') }}" id="" class="">

         {{ form.get('email').getLabel() }}

         {{ form.render('email') }}

         {% if form.getMessagesFor('email').count() > 0 %}
         {{ form.getMessagesFor('email').offsetGet(0).getMessage() }}
         {% endif %}

         {{ form.get('password').getLabel() }}

         {{ form.render('password') }}

         {% if form.getMessagesFor('password').count() > 0 %}
         {{ form.getMessagesFor('password').offsetGet(0).getMessage() }}
         {% endif %}

         {{ form.render('go') }}

from my experience I can say that 85% projects has normal forms without any unusual staff. For rest 15% webdevelopers can write their forms. Good framework makes your work much quicker and also when you would like to implemate something in another way you can also do this.

edited Aug '14

I agree with some parts of what you're saying and just for your information I don't have permission to edit or delete posts, I'm just a normal user.

btw you can just use {% if form.hasMessagesFor("field") %} instead of performing a count as well.

edited Aug '14

OK, sorry for this accusation. I hope that next Phalcon Framework version will have more useful staff like navigation, breadcrumbs, paginators, errorhandler etc.


Michael - if you want error handling, pagination for mongo etc. maybe try to check our Vegas CMF libs (more informations here: https://forum.phalcon.io/discussion/3116/vegas-cmf-v1-0-0-release).



Ok, good to know. In free time I will clone your project and give you feadback.



W dniu 2014-08-14 15:14, arius86 napisaƂ(a):