Replace "Enter some text" in Add Details Page

600
2
Jump to solution
12-22-2020 09:34 AM
DustinBaumbach1
Occasional Contributor

Hi All,

Some time ago it was suggested that I replace the placeholder text in the AddDetailsPage within quick report with something unique to each field. For example, I have a couple measurement and sample id fields that I would like to populate the placeholder text with "Enter a weight in kg", "Enter a measurement in cm", or "Enter a flipper tag number". I see the location of the placeholder text is within the Domain_Range.qml file, but I am not sure how to format the code to customize placeholder text for each individualized field. Is there an example of how to do this? How would the code be customized to accomplish this task?

0 Kudos
1 Solution

Accepted Solutions
ErwinSoekianto
Esri Regular Contributor

@DustinBaumbach1 

 

I think the current placeholderText logic is to check the fieldType then decide what text to show as place holder text, for example, if the type is text, then it is "Enter some text" or if the type is date, then it is "Pick a Date", 

 

 

placeholderText: fieldType == Enums.FieldTypeText ? qsTr("Enter some text") : fieldType == Enums.FieldTypeDate ? qsTr("Pick a Date") : qsTr("Enter a number")

 

In the same qml file, both QuickReport/controls/Domain_Range.qml and QuickReport/controls/EditControl.qml, you have access to fieldAlias, so you create a logic where the alias is "Weight", then the place holder text is "Enter weight in kg", etc. 

 

I hope this is helpful,

Erwin

 

 

View solution in original post

0 Kudos
2 Replies
ErwinSoekianto
Esri Regular Contributor

@DustinBaumbach1 

 

I think the current placeholderText logic is to check the fieldType then decide what text to show as place holder text, for example, if the type is text, then it is "Enter some text" or if the type is date, then it is "Pick a Date", 

 

 

placeholderText: fieldType == Enums.FieldTypeText ? qsTr("Enter some text") : fieldType == Enums.FieldTypeDate ? qsTr("Pick a Date") : qsTr("Enter a number")

 

In the same qml file, both QuickReport/controls/Domain_Range.qml and QuickReport/controls/EditControl.qml, you have access to fieldAlias, so you create a logic where the alias is "Weight", then the place holder text is "Enter weight in kg", etc. 

 

I hope this is helpful,

Erwin

 

 

0 Kudos
DustinBaumbach1
Occasional Contributor

Hi @ErwinSoekianto 

Thanks so much for your explanation. I understand the logic of the change, but am unsure how to actually implement changes to the code. I am sure I will have to create multiple customized lines of code, but would I change "Enter some text" in the placeholderText to "Enter a weight in kg" and then replace the first occurrence of "attributesArray[fieldName]" to "attributesArray[Weight]" in the text (see below)?

placeholderText: fieldType == Enums.FieldTypeText ? qsTr("Enter a Weight in kg") : fieldType == Enums.FieldTypeDate ? qsTr("Pick a Date") : qsTr("Enter a number")

text:  fieldType == Enums.FieldTypeDate ? (attributesArray[Weight] > "" ? new Date (attributesArray[fieldName]).toLocaleString(Qt.locale(), Qt.DefaultLocaleShortDate) : "") : (attributesArray[fieldName] || "")

If this is the case, how would I create multiple occurrences of "placeholderText" and "text"? Will these files accept multiple occurrences of placeholderText and text?

Thank you for your help.

Dustin

0 Kudos