Abstract Form Handling

I've already gone over some basic form handling and form best practices with my last few posts, but building with an object-orientated MVC starts to throw forms into a different light. It's very easy to abstract out forms with their repetitive logic patterns, something that I've recently done on one of my side projects. While I don't want to explain the code line-by-line, this post will go over some of the basic thought processes and steps I took to make my abstracted form handler.

Form Wrapper

The first logic I worked out was the definition of a form. To create each new form, I create a new class that is abstracting off a base pattern. Each form class defines form elements within a standard 'get' method. This way I can call on individual form elements easily or call the entire class to pull the whole form. Example...

read more »

Best Practices with Forms

The last post about PHP form handling (forms with php) focused on the basics - the HTML syntax and simple PHP necessary for an operating form. There were several pieces that I glossed over in the explanation for the setup of that form that I want to go over in more detail now. You can create a form using many different techniques... but some practices are better than others.

Use Standard Elements

By using Javascript or tweaking HTML elements you can create a working form without the standard form elements (input, textarea, checkbox, etc). Normal HTML form elements often have annoying default styles added to them by different browsers that may conflict with your design. While it may seem like a good idea to hack their behavior, there are two reasons why you shouldn't.

First, if you don't provide graceful degradation, there's a good chance that your tweaks may make your form unusable by more basic browsers and systems (like screen readers!). Second, users are used to certain ...

read more »

2011 New Year's Resolutions

It's that time of year again... When people realize that they've eaten too much food, spent too much money, or just haven't been overly productive over the holidays and decided to make firm New Year's Resolutions. I'm no exception to this annual tradition and have made a few commitments of my own for 2011.

Start working out

Original, eh? I am a pretty skinny guy (been hovering around 'underweight' for as long as I could spell the word), but working all day in front of a computer is not very conducive to a fit body. A few hiking-related knee injuries deter me from a daily run, but I do plan on exercising (standard push-ups and crunches) on a regular basis.
Goal: Be able to do 50 push-ups and 80 crunches in a single setting.

Finish my side projects

I've been working to get all of my sites under my MVC over the past year and feel pretty good about the progress I've made. While there is still the waterfall and hiking map sites that still use old school PHP, there is also a lot of cool features I've added to my ...

read more »