htmlGenerator

htmlGenerator is basically a just a handy way to output html code to your users for html

elements. I found it easier to work with,– so if I change the way I write forms, all elements are able to be changed in one simple little edit. htmlGenerator is an abstract class and as such, can’t be instantiated. You should use the defaultHtmlGenerator class if you want to create your own instance of it.

Parent Class

None


Public Methods

void textarea(array $settings)
void field(array $settings)
void select(array $settings)
void hint(array $settings)
void label(array $settings)
Each of these functions are merely HTML generators to help you write your view files. You certainly do NOT have to use these whatsoever. I like to use them since I can easily make one change to these and it takes effect for all the HTML elements I might want to have in a view.
Parameters:
$settings is an associative array (key=value pair). Below is a list of all the possible key values and which functions use them.

Most of the functions…

checkpostvars (boolean) If no value is set for the field, and this value is set to true, then the system will look at the $_POST vars to get a value. If none is set there, then checktemplatevars is considered.

checktemplatevars (boolean) If no value is set for the field, and this value is set to true, then the system will see if you have set the variable in template variables. If none is set there, then the table and field_name are used to get a value for the field.

class (string) html class value. default: “text ui-widget-content ui-corner-all” for everything but select() which has a default of “text ui-widget ui-corner-all”

disabled (string) html disabled value. default: none

field_name (string: required) name of the database field.

hint (array) key-value pairs that define a hint. default: none

id (string) html id value. default: none

label (string) label text

label_class (string) html class string for the label. default: ‘text’

label_style (string) html style string for the label. default: none

name (string) html name value. default: same as field_name key-value pair. name overrides field_name as the html name value if specified

showhints (boolean) show input hints? if a variable is named “whatever” then there would need to be another variable named “whatever_hint” in order for showhints to fire

style (string) html style value. default: none

table (table: required) an instance of a table object where the data is coming from

value (string) value to display in the input element. If none is specified, then the default behavior defined in this order: checkpostvars, checktemplatevars, database

field

maxlength (integer) html size and maxlength value. default: none

type (string): html type value. default: “text”

textarea

rows (integer) html rows value. default: none

cols (integer) html cols value. default: none

select

addfirst (boolean) true to add the option “Select One…” to the beginning of the options.

selected (string) determines which VALUE is selected

choices (array) key-value pair of choices for the select

hint

hint (string) string to be displayed as a hint to the input field.

name, id, class, style are the same as above, but must be in the array here as well.

Returns:
null. But each function ECHOs html code to the user obviously.

Example:
See template for a working example of how to use the html generators