Skip to content
Snippets Groups Projects
Commit a126f2b6 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Fixed a bug that date-/time inputs are rendered with a size=0 and/or maxlength=0.

Fixed a bug that Input fields are not rendered correctly the columntype are 'set' or 'enum'.
Support.php: doAttribute() - attributes with type 'size' or 'maxlenght' and no value or value=0 are skipped and not created.
AbstractBuild.php: a maxLenght formelement parameter needs to be numeric and (new) >0 to have an impact. Added calculation of maxlength for columntypes 'set' and 'enum': maxLengthSetEnum().
parent fb7dd7dc
No related branches found
No related tags found
No related merge requests found
......@@ -662,7 +662,7 @@ abstract class AbstractBuildForm {
// date/datetime
if ($maxLength !== false) {
if (is_numeric($formElement['maxLength'])) {
if (is_numeric($formElement['maxLength'] && $formElement['maxLength'] != '0')) {
if ($formElement['maxLength'] > $maxLength) {
$formElement['maxLength'] = $maxLength;
}
......@@ -691,6 +691,9 @@ abstract class AbstractBuildForm {
case 'time': // hh:mm:ss
return 8;
default:
if (substr($typeSpec, 0, 4) === 'set(' || substr($typeSpec, 0, 5) === 'enum(') {
return $this->maxLengthSetEnum($typeSpec);
}
break;
}
......@@ -703,6 +706,29 @@ abstract class AbstractBuildForm {
return false;
}
/**
* Get the strlen of the longest element in enum('val1','val2',...,'valn') or set('val1','val2',...,'valn')
*
* @param string $typeSpec
* @return int
*/
private function maxLengthSetEnum($typeSpec) {
$startPos = (substr($typeSpec, 0, 4) === 'set(') ? 4 : 5;
$max = 0;
$valueList = substr($typeSpec, $startPos, strlen($typeSpec) - $startPos - 1);
$valueArr = explode(',', $valueList);
foreach ($valueArr as $value) {
$value = trim($value, "'");
$len = strlen($value);
if ($len > $max) {
$max = $len;
}
}
return $max;
}
/**
* Builds a HTML attribute list, based on $attributeList.
*
......
......@@ -90,8 +90,21 @@ class Support {
* @return string
*/
public static function doAttribute($type, $value, $flagOmitEmpty = true) {
if ($flagOmitEmpty && $value === "")
if ($flagOmitEmpty && $value === "") {
return '';
}
switch ($type) {
case 'size':
case 'maxlength':
// empty or '0' for attributes of type 'size' or 'maxlenght' result in unsuable input elements: skip this.
if ($value === '' || $value == 0) {
return '';
}
break;
default:
break;
}
return $type . '="' . trim($value) . '" ';
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment