Home | Programming | Web Design | Contact Me  

RazorForm

RazorForm is a robust PHP library aimed at taking the grunt work out of dealing with HTML forms. Using a familiar HTML-like syntax, you tell RazorForm what fields you want in your form and what properties you want those fields to have, and RazorForm does the tedious stuff for you.

Among the tedious stuff about HTML forms is the need to make each input field and each row have the same look and feel. For this task, RazorForm generates HTML that includes a consistent and sensible arrangement of CSS elements. So most of the form's appearance is taken care of by simply creating style definitions for the CSS elements already in place after the form has been generated by RazorForm.

Another very common and tedious task is form validation. Usually, this means creating the form, having separate scripting that checks the user's input, and including code for each input field that shows the field's label differently (hightlighted in red, for example) if that field had an error. In RazorForm, you can specify that a field is required, must be a certain number of characters, must be the same value as that of another field (useful for password fields), or even must match a PHP regular expression that you define. For any error, you can specify the text of an error message that is displayed to the user. If a field has an error after submission, RazorForm simply changes the CSS elements associated with the field to be those that reflect an error. If the form designer has specified different styles for the error elements, the input field's display is affected as desired. You can also create a PHP function that does your own custom error checking, and RazorForm will call it internally, adding any error messages your code generates to that field's list of errors.

In addition to these features, RazorForm provides a slew of useful little conveniences to make the task as not-annoying as possible. For example, you can have the form definition in a separate file that both programmer and page designer have access to. Or you can set which character(s) will be globally used to separate the field labels if there are more than one field in a row (perhaps a comma followed by a space). Or you can arbitrarily create variables at the top of the form definition that will be used by various elements later on, for example, a variable that holds a size to be used by input fields that aren't the default size. There's even an object-oriented interface to RazorForm, so you could do this all programmatically.

RazorForm-0.10.tgz (tarball with documentation and samples)

RazorForm.php.txt (just the RazorForm utility itself - rename without the .txt to use it)

RazorForm User Guide (also included in the tarball above)