Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this questionHas 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 her开发者_JAVA百科e 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.
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".
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.
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:
- Create a table with forms (name, etc.) and a table with formfields (type, name, required)
- 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
. - 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.
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.
精彩评论