views:

135

answers:

4

Has anyone tips with building applications similar too wufoo.com? I am building an app where the logged in user creates forms in a similar manner...what i am wondering is if zend, symfony or yii is best suited for this?

I will be collecting tips here for other to see easier.

advantages of the frameworks that could help with this:

  • Symfony has doctrine (but forms are deployed by running a script?)
  • Zend has its form and subform integrations (and perhaps integrating doctrine is possible?)
  • Zend has form_decorators but they have a high threshold to learn.
  • yii has its form builder and a good PDO database connection

or are there any other frameworks that simplify "form generation on the fly"?

PS. djangos solution is very interesting but it needs to be in php.

+2  A: 

I can't think of any that specifically specialize in generating forms on the fly. This seems mostly like a Javascript based venture, so you'll likely end up using a heavy Javascript-based too.

Also, form generation isn't as easy as using a framework, especially for people who won't be using that specific framework. A lot of frameworks add in hidden fields or name the fields a certain way. I'm willing to bet it would end up more of a headache trying to make something for the general population using a pre-made framework than it would coming up with your own solution.

If you're adamant about using PHP to generate the forms, then I would skip the Javascript for now and come up with a solution that works with simple HTTP requests, and then look at using a JS framework to make your forms generate "dynamically".

Codeacula
+2  A: 

I don't know about the other frameworks but I can say this about the Zend Framework. Its Zend_Form class is very powerfull and flexible. It would be very well suited for a project like that but there is a steep learning curve to Zend_Element_Decorators.

With Zend you would store information about your form in a database using Zend_Db and use that to construct a Zend_Form using its addElement() function to create needed elements.

For sure using this is better then rolling up your own form generation. As far as I know there are no interface between Zend_Db and Zend_Form but you could very much write one. Zend is very flexible, you can pretty much do what you want.

Maybe the other frameworks are better for that I would not know.

Iznogood
Thanks. I have not yet looked at form_element_decorators but it looks promising. Right now i am working in Yii which has decent methods for rendering forms from arrays (of which this could possible be fetched from a database).
Mikelangelo
+1  A: 

Normally working with symfony I know that this is possible using symfony. You can generate forms on the fly in this manner. I think that Zend Framework does this in a similar way, so that would be an appropriate choice as well.

How you would do it in symfony, although it is "bending" the framework a bit:

  1. Create a table with forms (name, etc.) and a table with formfields (type, name, required)
  2. Create a sfForm class with a configure() method that pulls the fields for the given form and dynanically adds the form fields to $this->widgetSchema, and the validators to $this->validatorSchame.
  3. Go :)

This is somewhat not what the form framework is meant for (dynamic fields in this way), but I have successfully used it for some projects.

Regarding the Javascript mentioned by Codacula: I don't think there is anything in the question that propts the kind of Javascript usage that is mentioned. It is likely that some Javascript will go into this, but it is not part of the question in my opinion.

phidah
+1  A: 

Another form builder solution written in php worth checking out is http://code.google.com/p/php-form-builder-class/. I've used this in my web development and would recommend. It seems to be well-written and has saved me a lot of time getting projects up and running.