•TOC
Ex.4: Extending PClibIn this example we will create new class based on PCLib grid class. We want add possibility of checkboxes in database grid. For this purpose, we create new method print_checkbox() which will print checkbox html code and overload grid methods grid->print_element() which is called for printing each template tag and method grid->out() which do whole grid output. Here is the code:
In method print_element() we call our own handler for element of type check. For other elements we use default handling.In method out() we just add form tags around generated html. print_checkbox() print html code of the checkbox. It takes 3 arguments: $id is element name (identificator) specified in elements section, $sub is tag additional parameter (for example "lb" or "err") - not important here - and $value is value of element coming from values array. Method is called for each row of grid, at place where new check tag is used. We assume that ID of table row is in field ID. Posted data can be found in array $_POST['id_of_element']; Example of template:
Note that you must put {ID} (i.e. table rowid) into items block, because we use it in our method print_checkbox().Using this approach you can add new elements also at classes based on form class or tpl class. «PREV Using form |
VyhledáváníKam dál?Quickstart Malá ukázka použití jednotlivých komponent.Příručka Podrobnější popis použití jednotlivých tříd. V tuto chvíli pokrývá pouze tpl, form a grid. PClib App Začněte s šablonou pclib-app! Aktuální verze knihovny je 2.9.5. Changelog |