From ebd892e333b30ee1c15a3eb7843716c143b729fb Mon Sep 17 00:00:00 2001 From: Paolo Date: Fri, 21 Apr 2017 19:03:20 +0200 Subject: [PATCH] 2nd release --- application/libraries/WidgetLib.php | 30 ++++++++++++++++++++++++++ application/views/system/testudf.php | 2 +- application/views/widgets/dropdown.php | 2 +- application/widgets/UDF_widget.php | 5 +++-- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/application/libraries/WidgetLib.php b/application/libraries/WidgetLib.php index 7117deedb..d74692d0e 100644 --- a/application/libraries/WidgetLib.php +++ b/application/libraries/WidgetLib.php @@ -738,6 +738,36 @@ class DropdownWidget extends Widget private $elementsArray; // Array of elements to be place inside the dropdown + /** + * + */ + public function displayElements($elements, $widgetData) + { + $this->setElementsArray(success($this->convert($elements)), true); + $this->loadDropDownView($widgetData); + + echo $this->content(); + } + + /** + * + */ + public static function convert($elements) + { + $returnArray = array(); + + foreach($elements as $key => $val) + { + $element = new stdClass(); + $element->id = $key; + $element->description = $val; + + array_push($returnArray, $element); + } + + return $returnArray; + } + /** * Loads the dropdown view with all the elements to be displayed */ diff --git a/application/views/system/testudf.php b/application/views/system/testudf.php index c6635aa1c..9b6f7b75a 100644 --- a/application/views/system/testudf.php +++ b/application/views/system/testudf.php @@ -14,7 +14,7 @@ UDF_widget_tpl::TABLE_ARG_NAME => $table, UDF_widget_tpl::FIELD_ARG_NAME => $field ), - array('name' => 'schuhgroesse', 'id' => 'schuhgroesseUDF') + array('id' => 'schuhgroesseID', 'name' => 'schuhgroesseName') ); ?> diff --git a/application/views/widgets/dropdown.php b/application/views/widgets/dropdown.php index d511ece11..1c8ad8d15 100644 --- a/application/views/widgets/dropdown.php +++ b/application/views/widgets/dropdown.php @@ -2,7 +2,7 @@ {DropdownWidget::ID_FIELD} == ${DropdownWidget::SELECTED_ELEMENT}) + if ($element->{DropdownWidget::ID_FIELD} === ${DropdownWidget::SELECTED_ELEMENT}) { $selected = 'selected'; } diff --git a/application/widgets/UDF_widget.php b/application/widgets/UDF_widget.php index ebe0110f8..29a8757e2 100644 --- a/application/widgets/UDF_widget.php +++ b/application/widgets/UDF_widget.php @@ -50,7 +50,7 @@ class UDF_widget extends UDF_widget_tpl { if (isset($jsonSchema->type)) { - var_dump($jsonSchema); +// var_dump($jsonSchema); if ($jsonSchema->type == 'checkbox') { @@ -70,7 +70,8 @@ class UDF_widget extends UDF_widget_tpl } else if ($jsonSchema->type == 'dropdown') { - $dropdownWidget = new DropdownWidget(); + $dropdownWidget = new DropdownWidget($this->_name, $this->_args); + $dropdownWidget->displayElements($jsonSchema->listValues->enum, $this->_args); } else if ($jsonSchema->type == 'multipledropdown') {