Commit ff0bea2b authored by Carsten  Rose's avatar Carsten Rose
Browse files

Fixed rendering of ' checkbox'. formelement.parameter['orientation'] removed...

Fixed rendering of ' checkbox'. formelement.parameter['orientation'] removed (replace by formelement.maxLength)
UserManual/index.rst: Doc updated for checkbox/maxlength.
AbstractBuildForm.php, Constants.php: class 'checkbox' and 'checkbox-inline' always rendered. Insert <br> where necessary.
parent 1f978fd0
......@@ -594,9 +594,9 @@ Class: Native
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
|tabindex | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
|size | - 1 | | | | | - | | - | - 1| - 2 | | - 1 | - | - ? |
|size | - | | | | | - | | - | - | - 2 | | - 1 | - | - ? |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
|maxLength | | | | | | - | | - | | | | | | |
|maxLength | 1 | | | | | - | | - | - 1 | | | | | |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
|note | - | - | - | | | - | - | - | - | - | - | - | - | - |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
......@@ -681,13 +681,17 @@ Checkboxes can be rendered in mode:
* *parameter*
* *checkBoxMode*: multi
* *orientation*: vertical | horizontal (default), optional - the checkboxes are rendered horizontal or vertical.
* *itemList* - E.g.:
* ``itemList=red,blue,orange``
* ``itemList=1:red,2:blue,3:orange``
* ``itemList={{!SELECT id, value FROM someTable}}``
* FormElement '''Maxlength''' - vertical or horizontal alignment:
* Value: '', 0, 1 - The radios will be aligned vertical.
* Value: >1 - The readios will be aligned horizontal, with a linebreak every 'value' elements.
Type: date
^^^^^^^^^^
......@@ -738,11 +742,10 @@ Type: radio
* c) Definition of the *enum* or *set* field (only labels, no ids are possible).
* FormElement '''Maxlength''' - Vertical or Horizontal alignment:
* '', 0, 1: Vertical.
* >1: every n'th elements a `<br>`.
* FormElement '''Maxlength''' - *vertical* or *horizontal* alignment:
* Value: '', 0, 1 - The radios will be aligned vertical.
* Value: >1 - The readios will be aligned horizontal, with a linebreak every 'value' elements.
* FormElement.'''parameter''':
......
......@@ -1056,6 +1056,9 @@ abstract class AbstractBuildForm {
* @return string
*/
public function buildCheckboxMulti(array $formElement, $htmlFormElementId, $attributeBase, $value, array $itemKey, array $itemValue) {
$orientation = '';
$br = '';
// Defines which of the checkboxes will be checked.
$values = explode(',', $value);
......@@ -1064,7 +1067,14 @@ abstract class AbstractBuildForm {
$html = $this->buildNativeHidden($htmlFormElementId, '');
$orientation = (isset($formElement[CHECKBOX_ORIENTATION]) && $formElement[CHECKBOX_ORIENTATION] === 'vertical') ? '' : 'checkbox-inline';
if ($formElement['maxLength'] > 1) {
$orientation = 'checkbox-inline';
$checkboxClass = 'checkbox-inline';
} else {
$checkboxClass = 'checkbox';
}
// $orientation = (isset($formElement[CHECKBOX_ORIENTATION]) && $formElement[CHECKBOX_ORIENTATION] === 'vertical') ? '' : 'checkbox-inline';
$flagFirst = true;
for ($ii = 0, $jj = 1; $ii < count($itemKey); $ii++, $jj++) {
......@@ -1085,19 +1095,30 @@ abstract class AbstractBuildForm {
$attribute .= Support::doAttribute('checked', 'checked');
}
$htmlCheckbox = '<input ' . $attribute . '>';
$htmlCheckbox .= $itemValue[$ii];
// '&nbsp;' - This is necessary to correctly align an empty input.
$value = ($itemValue[$ii] === '') ? '&nbsp;' : $itemValue[$ii];
$htmlElement = '<input ' . $attribute . '>' . $value;
$htmlCheckbox = Support::wrapTag("<label class='$orientation'>", $htmlCheckbox, true);
if (isset($formElement[CHECKBOX_ORIENTATION]) && $formElement[CHECKBOX_ORIENTATION] === 'vertical')
$htmlCheckbox = Support::wrapTag("<div class='checkbox'>", $htmlCheckbox, true);
$htmlElement = Support::wrapTag("<label class='$orientation'>", $htmlElement, true);
$htmlElement = Support::wrapTag("<div class='$checkboxClass'>", $htmlElement, true);
if ($formElement['maxLength'] > 1) {
$html .= $htmlCheckbox;
if ($jj == $formElement['maxLength']) {
$jj = 0;
$br = '<br>';
} else {
$br = '';
}
}
if (isset($formElement[CHECKBOX_ORIENTATION]) && $formElement[CHECKBOX_ORIENTATION] !== 'vertical')
$html = Support::wrapTag("<div class='checkbox'>", $html, true);
$html .= $htmlElement . $br;
}
// if (isset($formElement[CHECKBOX_ORIENTATION]) && $formElement[CHECKBOX_ORIENTATION] !== 'vertical')
// $html = Support::wrapTag("<div class='checkbox'>", $html, true);
//
return $html;
}
......@@ -1167,7 +1188,10 @@ abstract class AbstractBuildForm {
$attribute .= Support::doAttribute('checked', 'checked');
}
$element = '<input ' . $attribute . '>' . $itemValue[$ii];
// '&nbsp;' - This is necessary to correctly align an empty input.
$value = ($itemValue[$ii] === '') ? '&nbsp;' : $itemValue[$ii];
$htmlElement = '<input ' . $attribute . '>' . $value;
// $element = Support::wrapTag('<label>',$element);
......@@ -1185,9 +1209,9 @@ abstract class AbstractBuildForm {
}
}
$element = Support::wrapTag("<div class='$radioClass'>", $element) . $br;
$htmlElement = Support::wrapTag("<div class='$radioClass'>", $htmlElement) . $br;
$html .= $element;
$html .= $htmlElement;
}
$json = $this->getJsonElementUpdate($htmlFormElementId, $value, $formElement[FE_MODE]);
......
......@@ -345,7 +345,7 @@ const SYMBOL_DELETE = 'delete';
//CHECKBOX
const CHECKBOX_VALUE_CHECKED = 'checked';
const CHECKBOX_VALUE_UNCHECKED = 'unchecked';
const CHECKBOX_ORIENTATION = 'orientation';
//const CHECKBOX_ORIENTATION = 'orientation';
// Subrecord
const SUBRECORD_COLUMN_WIDTH = 20;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment