1

I want a library to generate standards compliant HTML form.

Some expected features:

  • Efficiency with large form fields
  • Validation (client side /server side)
Gajus
  • 69,002
  • 70
  • 275
  • 438
sakhunzai
  • 13,900
  • 23
  • 98
  • 159

3 Answers3

1

The Zend framework has fairly advanced forms support, which can be used standalone (i.e. without having to the Zend MVC framework).

Jonahlyn Gilstrap has done a great write up of how to do this: http://jonahlyn.heroku.com/blog/2011/04/06/using-zend-form-without-the-framework

It's certainly a good idea if you are planning to do several forms, but using a framework for them may be overkill if you only need one or two forms (if only because it may in practice limit how you can lay out and style them).

Iain Collins
  • 6,774
  • 3
  • 43
  • 43
  • you are right almost , but I wonder if someone has already wrote this piece of code and I(we) missed(ignored) it. I want to hear from others. I ll set some bounty if some one comes up with nice reference. – sakhunzai Dec 10 '12 at 13:29
1

If forms are a recurring element of your application, you should choose kind of a library to keep them consistent for sure, being it either yours or third party, over vanilla HTML code [which you'll be generating as output as well, of course].

You can use the form component from Symfony [guide here], which will imply using the Request component as well because you'll want to bind the request itself to the form, validate the input, and so.

moonwave99
  • 21,957
  • 3
  • 43
  • 64
0

In frameworks you often have an engine that can do this for you. For example in cakephp you can use functions from the FormHelper class as so:

echo $this->Form->create();
echo $this->Form->input('User.name');
echo $this->Form->end();

There is no such thing as a "The Form library" but you can imagine it's not that difficult to create a nice class for yourself which can handle a lot of your html generation.

Jelmer
  • 2,663
  • 2
  • 27
  • 45
  • I know about them the best on I see is provided by Yii framework. My concern is sth that is standalone lib . However, thanks for your feedback :) – sakhunzai Dec 10 '12 at 13:22
  • Your welcome. It think it's pretty easy to modify it though. The FormHelper is not that complicated :) But I can understand that it might be to much work. Developers are lazy.. Including me. – Jelmer Dec 10 '12 at 13:29