diff --git a/application/libraries/WidgetLib.php b/application/libraries/WidgetLib.php index 5577db08c..15c90cfbd 100644 --- a/application/libraries/WidgetLib.php +++ b/application/libraries/WidgetLib.php @@ -875,6 +875,9 @@ class DropdownWidget extends Widget } } +/** + * + */ class DropdownWidgetUDF extends DropdownWidget { /** @@ -907,6 +910,50 @@ class DropdownWidgetUDF extends DropdownWidget } } +/** + * It exends the Widget class to represent an HTML textarea + */ +class TextareaWidget extends Widget +{ + const TEXT = 'text'; // + const ROWS = 'rows'; // + const COLS = 'cols'; // + + /** + * + */ + protected function setText($text) + { + $this->_args[DropdownWidget::TEXT] = $text; + } + + /** + * + */ + protected function loadTextareaView() + { + $this->view('widgets/textarea', $this->_args); + } +} + +/** + * + */ +class TextareaWidgetUDF extends TextareaWidget +{ + /** + * + */ + public function render($parameters) + { + $this->setText($parameters); + + $this->loadTextareaView(); + + echo $this->content(); + } +} + /** * */ diff --git a/application/widgets/UDFWidget.php b/application/widgets/UDFWidget.php index 4d9f926ed..a2686729a 100644 --- a/application/widgets/UDFWidget.php +++ b/application/widgets/UDFWidget.php @@ -133,7 +133,7 @@ class UDFWidget extends UDFWidgetTpl } else if ($jsonSchema->type == 'textarea') { - + $this->_renderTextarea($jsonSchema); } else if ($jsonSchema->type == 'date') { @@ -156,15 +156,15 @@ class UDFWidget extends UDFWidgetTpl { $dropdownWidgetUDF = new DropdownWidgetUDF($this->_name, $this->_args); - $paramters = array(); + $parameters = array(); if (isset($jsonSchema->listValues->enum)) { - $paramters = $jsonSchema->listValues->enum; + $parameters = $jsonSchema->listValues->enum; } else if (isset($jsonSchema->listValues->sql)) { - $paramters = $jsonSchema->listValues->sql; + $parameters = $jsonSchema->listValues->sql; } if ($multiple) @@ -172,7 +172,23 @@ class UDFWidget extends UDFWidgetTpl $dropdownWidgetUDF->setMultiple(); } - $dropdownWidgetUDF->render($paramters); + $dropdownWidgetUDF->render($parameters); + } + + /** + * + */ + private function _renderTextarea($jsonSchema) + { + $textareaUDF = new TextareaUDF($this->_name, $this->_args); + + $text = ''; + if (isset($jsonSchema->defaultValue)) + { + $text = $jsonSchema->defaultValue; + } + + $textareaUDF->render($text); } /**