From a67f718157febd5617904433e924238fbc246a35 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 25 Dec 2006 22:55:50 +0000 Subject: [PATCH] - Added BSPrinterTableElement::RowTextarea() - Added textarea support to BSPrinterBaseElement --- PrinterBaseElement.php | 17 ++++++++++++++++- PrinterTableElement.php | 20 ++++++++++++++++++++ printer.php | 18 +----------------- 3 files changed, 37 insertions(+), 18 deletions(-) diff --git a/PrinterBaseElement.php b/PrinterBaseElement.php index ce68dc9..8586540 100644 --- a/PrinterBaseElement.php +++ b/PrinterBaseElement.php @@ -81,6 +81,11 @@ class BSPrinterBaseElement extends BSPrinterElement $this->name = $name; $this->value = $value; $this->setCssClass('input'); + + if ($type == 'textarea') + { + $this->setStyle(array('width' => '100%', 'height' => '50px')); + } } // ################################################################### @@ -94,7 +99,7 @@ class BSPrinterBaseElement extends BSPrinterElement { if (!in_array($this->type, array('checkbox', 'radio', 'option'))) { - trigger_error('PrinterBaseElement::setActive() can only be used on elements of type checkbox, radio, or option'); + trigger_error('BSPrinterBaseElement::setActive() can only be used on elements of type checkbox, radio, or option'); } $this->active = $active; } @@ -186,6 +191,16 @@ class BSPrinterBaseElement extends BSPrinterElement case 'select': return '_prepareStyle() . '>' . $this->value . ''; + break; + + case 'textarea': + if (!isset($this->style['height']) OR !isset($this->style['width'])) + { + trigger_error('BSPrinterBaseElement of type "textarea" require a "height" and "width" style attribute'); + } + + return '_prepareStyle() . '>' . $this->value . ''; + break; default: trigger_error('Invalid PrinterBaseElement type "' . $this->type . '"'); diff --git a/PrinterTableElement.php b/PrinterTableElement.php index f3e7d9c..2e5d33e 100644 --- a/PrinterTableElement.php +++ b/PrinterTableElement.php @@ -270,6 +270,26 @@ class BSPrinterTableElement extends BSPrinterElement return $tr; } + // ################################################################### + /** + * Prints a row with a textarea + * + * @param string Label + * @param string Textarea name + * @param string Value to fill with + * + * @return BSPrinterTableElement Table row + */ + public static function RowTextarea($label, $name, $value = null) + { + $tr = new BSPrinterTableElement(); + + $tr->addChild(new BSPrinterLabelElement($label)); + $tr->addChild(new BSPrinterBaseElement('textarea', $name, $value)); + + return $tr; + } + // ################################################################### /** * Returns the number of columns in this element diff --git a/printer.php b/printer.php index b0be961..e969329 100644 --- a/printer.php +++ b/printer.php @@ -56,23 +56,7 @@ require_once('ISSO/PrinterTableElement.php'); */ class Printer { - // ################################################################### - /** - * Creates a table row with a ", 'top', $colspan); - } + } /*=====================================================================*\ -- 2.22.5