Jump to content

Recommended Posts

Is it worthwhile to create an object to generate my HTML forms? 

 

Starting out it would appear to be worthwhile but I'm not sure how things might change later down the line when I'm doing more with my forms and introducing javascript to it.  It's a bunch of coding to change all my forms now so I wanted to hear some input before I started.  Would this be just a complete waste of server side processing?

 

TIA!  8)

Link to comment
https://forums.phpfreaks.com/topic/249073-oop-html-forms/
Share on other sites

It all depends on your needs.  I created a class that handles input's (not the whole form), then I have a  validation class that automatically validates the inputs.  This takes loads of work off of me, as I only need to set the validation rules for the inputs.  It is also written in a way that I can add any javascript that I need as well.

 

The question isn't "is is worthwhile", the question is "can you make it open ended enough".

Link to comment
https://forums.phpfreaks.com/topic/249073-oop-html-forms/#findComment-1279171
Share on other sites

As DevilsAdvocate said there's plenty already out there, or as jcbones mentioned you could create your own. Just a matter of preference really and

"is is worthwhile"
Personally I prefer to just to type up forms myself, and keep the validation separate.
Link to comment
https://forums.phpfreaks.com/topic/249073-oop-html-forms/#findComment-1279185
Share on other sites

Thanks for all the replies, I've been writing something for myself so it suits my needs and also for the learning.

 

All my class variables are private.  I am only letting values be set through the constructor, am I okay to not create accessor functions?

 

 

  private $css_class;	// css style for the form (defaults to "user_form")
  private $action;	// where form is submitted to 
  private $legend;	// legend text value (defaults to blank string)
  private $method;	// method (defaults to post)
  private $html;	// html code for the form

Link to comment
https://forums.phpfreaks.com/topic/249073-oop-html-forms/#findComment-1280119
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.