From 6b857a500d3904160d3c747ff8d4d1137e25feda Mon Sep 17 00:00:00 2001 From: Carsten Rose <carsten.rose@math.uzh.ch> Date: Tue, 3 May 2016 12:13:45 +0200 Subject: [PATCH] Radio-buttons: vertical & horizontal alignent. AbstractBuildForm.php: Class 'radio' or 'radio-inline' assigned to each individual radio element. After formelement['maxlength'] elements, a <br> is rendered. --- extension/qfq/qfq/AbstractBuildForm.php | 20 +++++++++++++++----- extension/qfq/sql/testtables.sql | 3 ++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/extension/qfq/qfq/AbstractBuildForm.php b/extension/qfq/qfq/AbstractBuildForm.php index 72b73b83d..a0893a390 100644 --- a/extension/qfq/qfq/AbstractBuildForm.php +++ b/extension/qfq/qfq/AbstractBuildForm.php @@ -1147,10 +1147,13 @@ abstract class AbstractBuildForm { $jj = 0; $flagFirst = true; + $radioClass = ($formElement['maxLength'] > 1) ? 'radio-inline' : 'radio'; + $br = ''; + $html = $this->buildNativeHidden($htmlFormElementId, $value); for ($ii = 0; $ii < count($itemValue); $ii++) { $jj++; - $attribute = $attributeBase; + $attribute = $attributeBase; // if ($flagFirst) { $flagFirst = false; if (isset($formElement['autofocus'])) @@ -1172,12 +1175,19 @@ abstract class AbstractBuildForm { // $element = Support::wrapTag('<div class="' . $this->feDivClass[$formElement[FE_TYPE]] .'">', $element); // } - $html .= $element; + if ($formElement['maxLength'] > 1) { - if ($jj === $formElement['maxLength']) { - $jj = 0; - $html .= '<br>'; + if ($jj == $formElement['maxLength']) { + $jj = 0; + $br = '<br>'; + } else { + $br = ''; + } } + + $element = Support::wrapTag("<div class='$radioClass'>", $element) . $br; + + $html .= $element; } $json = $this->getJsonElementUpdate($htmlFormElementId, $value, $formElement[FE_MODE]); diff --git a/extension/qfq/sql/testtables.sql b/extension/qfq/sql/testtables.sql index 392c4573c..877bb804c 100644 --- a/extension/qfq/sql/testtables.sql +++ b/extension/qfq/sql/testtables.sql @@ -60,7 +60,8 @@ VALUES (500, 5, 'name', 'Name', 'show', 'text', 'all', 'native', 10, 0, 255, '', '', '', '', '', '', 0, ''), (501, 5, 'firstname', 'Firstname', 'show', 'text', 'all', 'native', 20, 0, 255, '', '', '', '', '', '', 0, ''), (502, 5, 'birthday', 'Birthday', 'show', 'date', 'all', 'native', 30, 0, 255, '', '', '', '', '', '', 0, ''), - (506, 5, 'gender', 'Sex', 'show', 'select', 'alnumx', 'native', 40, 0, 0, '', '', '', '', '', '', 0, ''), + (506, 5, 'gender', 'Sex', 'show', 'radio', 'alnumx', 'native', 40, 0, 0, '', '', '', '', '', 'itemList=female,male', + 0, ''), (503, 5, 'datumZeit', 'Datum & Zeit', 'show', 'datetime', 'alnumx', 'native', 50, 0, 0, '', '', '', '', '', '', 0, ''), (504, 5, 'zeit', 'Zeit', 'show', 'time', 'alnumx', 'native', 60, 0, 0, '', '', '', '', '', '', 0, ''), -- GitLab