Show helptext for params when generating new report

This commit is contained in:
Lance Edgar 2022-01-31 16:52:16 -06:00
parent 16a4fe1a4f
commit 4716545b7e
2 changed files with 8 additions and 1 deletions

View file

@ -9,6 +9,9 @@
% if isinstance(field.schema.typ, deform.FileData): % if isinstance(field.schema.typ, deform.FileData):
class="file" class="file"
% endif % endif
% if form.has_helptext(field.name):
message="${form.render_helptext(field.name)}"
% endif
% if error_messages: % if error_messages:
type="is-danger" type="is-danger"
:message='${form.messages_json(error_messages)|n}' :message='${form.messages_json(error_messages)|n}'

View file

@ -401,6 +401,7 @@ class GenerateReport(View):
} }
schema = colander.Schema() schema = colander.Schema()
helptext = {}
for param in report_params: for param in report_params:
# make a new node of appropriate schema type # make a new node of appropriate schema type
@ -420,10 +421,13 @@ class GenerateReport(View):
if hasattr(param, 'default'): if hasattr(param, 'default'):
node.default = param.default node.default = param.default
# set docstring
helptext[param.name] = param.helptext
schema.add(node) schema.add(node)
form = forms.Form(schema=schema, request=self.request, form = forms.Form(schema=schema, request=self.request,
use_buefy=use_buefy) use_buefy=use_buefy, helptext=helptext)
form.submit_label = "Generate this Report" form.submit_label = "Generate this Report"
form.cancel_url = self.request.route_url('generate_report') form.cancel_url = self.request.route_url('generate_report')