Commit 99c71706 authored by Carsten  Rose's avatar Carsten Rose
Browse files

#4299 / HTML Element 'Select': Placeholder

AbstractBuildForm.php: code cleanup
parent 455f40db
......@@ -82,48 +82,48 @@ abstract class AbstractBuildForm {
$this->buildElementFunctionName = [
FE_TYPE_CHECKBOX => 'Checkbox',
FE_TYPE_DATE => 'DateTime',
FE_TYPE_DATE => 'DateTime',
FE_TYPE_DATETIME => 'DateTime',
'dateJQW' => 'DateJQW',
'datetimeJQW' => 'DateJQW',
'email' => 'Input',
'gridJQW' => 'GridJQW',
FE_TYPE_EXTRA => 'Extra',
FE_TYPE_TEXT => 'Input',
FE_TYPE_EDITOR => 'Editor',
FE_TYPE_TIME => 'DateTime',
FE_TYPE_NOTE => 'Note',
'dateJQW' => 'DateJQW',
'datetimeJQW' => 'DateJQW',
'email' => 'Input',
'gridJQW' => 'GridJQW',
FE_TYPE_EXTRA => 'Extra',
FE_TYPE_TEXT => 'Input',
FE_TYPE_EDITOR => 'Editor',
FE_TYPE_TIME => 'DateTime',
FE_TYPE_NOTE => 'Note',
FE_TYPE_PASSWORD => 'Input',
FE_TYPE_RADIO => 'Radio',
FE_TYPE_SELECT => 'Select',
FE_TYPE_RADIO => 'Radio',
FE_TYPE_SELECT => 'Select',
FE_TYPE_SUBRECORD => 'Subrecord',
FE_TYPE_UPLOAD => 'File',
'fieldset' => 'Fieldset',
'pill' => 'Pill',
'templateGroup' => 'TemplateGroup',
FE_TYPE_UPLOAD => 'File',
'fieldset' => 'Fieldset',
'pill' => 'Pill',
'templateGroup' => 'TemplateGroup',
];
$this->buildRowName = [
FE_TYPE_CHECKBOX => 'Native',
FE_TYPE_DATE => 'Native',
FE_TYPE_DATE => 'Native',
FE_TYPE_DATETIME => 'Native',
'dateJQW' => 'Native',
'datetimeJQW' => 'Native',
'email' => 'Native',
'gridJQW' => 'Native',
FE_TYPE_EXTRA => 'Native',
FE_TYPE_TEXT => 'Native',
FE_TYPE_EDITOR => 'Native',
FE_TYPE_TIME => 'Native',
FE_TYPE_NOTE => 'Native',
'dateJQW' => 'Native',
'datetimeJQW' => 'Native',
'email' => 'Native',
'gridJQW' => 'Native',
FE_TYPE_EXTRA => 'Native',
FE_TYPE_TEXT => 'Native',
FE_TYPE_EDITOR => 'Native',
FE_TYPE_TIME => 'Native',
FE_TYPE_NOTE => 'Native',
FE_TYPE_PASSWORD => 'Native',
FE_TYPE_RADIO => 'Native',
FE_TYPE_SELECT => 'Native',
FE_TYPE_RADIO => 'Native',
FE_TYPE_SELECT => 'Native',
FE_TYPE_SUBRECORD => 'Subrecord',
FE_TYPE_UPLOAD => 'Native',
'fieldset' => 'Fieldset',
'pill' => 'Pill',
'templateGroup' => 'TemplateGroup',
FE_TYPE_UPLOAD => 'Native',
'fieldset' => 'Fieldset',
'pill' => 'Pill',
'templateGroup' => 'TemplateGroup',
];
$this->symbol[SYMBOL_EDIT] = "<span class='glyphicon " . GLYPH_ICON_EDIT . "'></span>";
......@@ -260,7 +260,7 @@ abstract class AbstractBuildForm {
$queryStringArray = [
'id' => $this->store->getVar(SYSTEM_EDIT_FORM_PAGE, STORE_SYSTEM),
'form' => $form,
'r' => $recordId,
'r' => $recordId,
];
$queryStringArray = array_merge($queryStringArray, $param);
......@@ -1114,13 +1114,13 @@ abstract class AbstractBuildForm {
}
$arr = [
FE_LDAP_SERVER => $formElement[FE_LDAP_SERVER],
FE_LDAP_BASE_DN => $formElement[FE_LDAP_BASE_DN],
FE_TYPEAHEAD_LDAP_SEARCH => $formElement[FE_TYPEAHEAD_LDAP_SEARCH],
FE_LDAP_SERVER => $formElement[FE_LDAP_SERVER],
FE_LDAP_BASE_DN => $formElement[FE_LDAP_BASE_DN],
FE_TYPEAHEAD_LDAP_SEARCH => $formElement[FE_TYPEAHEAD_LDAP_SEARCH],
FE_TYPEAHEAD_LDAP_SEARCH_PREFETCH => $formElement[FE_TYPEAHEAD_LDAP_SEARCH_PREFETCH],
FE_TYPEAHEAD_LDAP_VALUE_PRINTF => $formElement[FE_TYPEAHEAD_LDAP_VALUE_PRINTF],
FE_TYPEAHEAD_LDAP_ID_PRINTF => $formElement[FE_TYPEAHEAD_LDAP_ID_PRINTF],
FE_TYPEAHEAD_LIMIT => $formElement[FE_TYPEAHEAD_LIMIT],
FE_TYPEAHEAD_LDAP_ID_PRINTF => $formElement[FE_TYPEAHEAD_LDAP_ID_PRINTF],
FE_TYPEAHEAD_LIMIT => $formElement[FE_TYPEAHEAD_LIMIT],
];
if (isset($formElement[FE_TYPEAHEAD_LDAP_SEARCH_PER_TOKEN])) {
......@@ -1457,7 +1457,6 @@ abstract class AbstractBuildForm {
* @param array $itemKey
* @param array $itemValue
*
* @return array
* @throws CodeException
* @throws \qfq\UserFormException
*/
......@@ -1510,24 +1509,17 @@ abstract class AbstractBuildForm {
$itemValue = OnArray::removeEmptyElementsFromArray($itemValue);
}
$placeholder = isset($formElement[FE_PLACEHOLDER]) ? $formElement[FE_PLACEHOLDER] : '';
// If a placeholder is configured but no emptyItemAtStart nor emptyItemAtEnd: force emptyItemAtStart
if ($placeholder != '' && !isset($formElement[FE_EMPTY_ITEM_AT_START]) && !isset($formElement[FE_EMPTY_ITEM_AT_END])) {
$formElement[FE_EMPTY_ITEM_AT_START] = '';
}
if (isset($formElement[FE_EMPTY_ITEM_AT_START])) {
$placeholder = isset($formElement[FE_PLACEHOLDER]) ? $formElement[FE_PLACEHOLDER] : '';
array_unshift($itemKey, '');
array_unshift($itemValue, $placeholder);
}
if (isset($formElement[FE_EMPTY_ITEM_AT_END])) {
$itemKey[] = '';
$itemValue[] = $placeholder;
$itemValue[] = '';
}
return $formElement;
}
/**
......@@ -2216,8 +2208,15 @@ abstract class AbstractBuildForm {
$itemValue = array();
$attribute = '';
if (!empty($formElement[FE_PLACEHOLDER])) {
$formElement[FE_EMPTY_ITEM_AT_START] = '';
if (isset($formElement[FE_EMPTY_ITEM_AT_END])) {
unset($formElement[FE_EMPTY_ITEM_AT_END]);
}
}
// Fill $itemKey & $itemValue
$formElement = $this->getKeyValueListFromSqlEnumSpec($formElement, $itemKey, $itemValue);
$this->getKeyValueListFromSqlEnumSpec($formElement, $itemKey, $itemValue);
$attribute .= $this->getAttributeFeMode($formElement[FE_MODE]);
$attribute .= Support::doAttribute('id', $formElement[FE_HTML_ID]);
......@@ -2242,12 +2241,8 @@ abstract class AbstractBuildForm {
$option .= Support::doAttribute('value', $itemKey[$ii], false);
if ($formElement[FE_PLACEHOLDER] != '') {
if (($ii == 0 && isset($formElement[FE_EMPTY_ITEM_AT_START])) ||
($ii == $total - 1 && isset($formElement[FE_EMPTY_ITEM_AT_END]))
) {
$option .= 'disabled hidden ';
}
if ($ii == 0 && $formElement[FE_PLACEHOLDER] != '') {
$option .= 'disabled hidden ';
}
$jsonValues[] = [
......
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