Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Best practices to handle forms in Phalcon Php

Hi there,

As a new beginner in Phalcon Php, i was wondering what's the best pratices to handle forms and validation components in the MVC. I used to work with Zend Framework, and Code Igniter before, and started to hear a lot about Phalcon.

Forms are common components in a web application, and i'd like to know what's your best purpose to handle them in Phalcon.

For the time, my application folder is set like this : I also have a "config" folder in the app one.

If i want to use many forms like "login", "register" etc. What do you advice me ? Creating a "helper" folder ? Sets a config file where all forms validation rules are sets (like CodeIgniter) ?

The goal is to have an easy way to manage all the forms in the application, just construct them in controllers, and check if their valids. Sorry for my bad spelling, i'm french :o)



Check out the vokuro project the phalcon team did.

It uses form classes to define how the inputs should render, and then uses the form class to validate in the controller. Inspect the session controller and the register/login forms that accompany it to give you a good idea of how to set it up.

Then when you are comfortable with phalcon form generation and are interested in more dynamic form inputs they give a good example in the wiki on how to do a dependant drop down: and fill dynamically from other models:


Sounds great :-) Thank you David.