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