Required text fields

merge-requests/30/head
Bob Mottram 2021-07-27 19:31:50 +01:00
parent f91d93ba05
commit 9358e9bd2c
2 changed files with 7 additions and 4 deletions

View File

@ -360,9 +360,9 @@ def htmlNewPost(cssCache: {}, mediaInstance: bool, translate: {},
'itemQty', 1, 1, 999999, 1)
extraFields += '<br>' + \
editTextField(translate['Type of shared item. eg. hat'] + ':',
'itemType', '')
'itemType', '', '', True)
catStr = translate['Category of shared item. eg. clothing']
extraFields += editTextField(catStr + ':', 'category', '')
extraFields += editTextField(catStr + ':', 'category', '', '', True)
extraFields += '<br>'
extraFields += \
editNumberField(translate['Duration of listing in days'],

View File

@ -1155,7 +1155,7 @@ def endEditSection() -> str:
def editTextField(label: str, name: str, value: str = "",
placeholder: str = "") -> str:
placeholder: str = "", required: bool = False) -> str:
"""Returns html for editing a text field
"""
if value is None:
@ -1163,10 +1163,13 @@ def editTextField(label: str, name: str, value: str = "",
placeholderStr = ''
if placeholder:
placeholderStr = ' placeholder="' + placeholder + '"'
requiredStr = ''
if required:
requiredStr = ' required'
return \
'<label class="labels">' + label + '</label><br>\n' + \
' <input type="text" name="' + name + '" value="' + \
value + '"' + placeholderStr + '>\n'
value + '"' + placeholderStr + requiredStr + '>\n'
def editNumberField(label: str, name: str, value: int = 1,