Andrew Plummer - Design Development Translation

Example 9: Injecting Custom HTML

Summary

For us control freaks out there, custom HTML can be added at key points in the table or form element using the custom option.

Example

View Example

PHP Code

$tg = new TableGear(array( "database" => array( "username" => "USERNAME", "password" => "PASSWORD", "database" => "DATABASE", "table" => "TABLE" ), "sortable" => "all", "editable" => "all", "loading" => array( "tag" => "img", "attrib" => array( "src" => "/images/icons/loading.gif", "alt" => "Loading...", "class" => "loading" ) ), "formatting" => array( "price" => "currency[prefix=$,pad], "date" => "date" ), "totals" => array("price", 5), "custom" => array( "FORM_TOP" => array( "tag" => "div", "attrib" => array("class" => "textTop"), "html" => array( "tag" => "p", "html" => "Hello...I'm at the top!" ) ) ) );

Custom HTML can be complicated, as it takes nested HTML objects as a parameter, but this is also what makes it so powerful. In the example, we are saying to inject a p element with text inside a div element with the class "textTop" just inside the form element. Have a look at the source HTML of the example to see the result.

For more information about the places custom HTML can be injected and more information about how to use HTML objects, see the documentation.