Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,47 @@ form element based on the selected option in a select widget.
value: 1

In this case, selecting Node Type 'small' will change the label of Cores to
'Number of Cores (1-4)'.
'Number of Cores (1-4)'. Note that options without directives will leave the
label unchanged from it's last value, and will not restore the default label.

.. _dynamic-bc-apps-data-help:

Dynamic Help Text
*****************

The ``data-help-*`` directive allows you to change the help text of another
form element based on the selected option in a select widget.

.. code-block:: yaml

attributes:
group:
widget: 'select'
label: Membership group
help: 'you can find your group in your personal page'
options:
- ['First', data-help-hard-choice: 'Choose Anything']
- ['Second', data-help-hard-choice: 'Choose No']
- ['Third', data-help-hard-choice: 'Choose Yes']
hard_choice:
widget: 'radio_button'
label: 'Make your choice'
options:
- ["Yes", "1"]
- ["No", "0"]
- ["Maybe", "i"]

In this case, the ``hard_choice`` radio button begins with help text reading 'Choose Anything' since
'First' is the default value of the ``group`` select. Choosing 'Second' or 'Third' from the group
select will change the help text of the ``hard_choice`` radio button to nudge the user one way or
the other. If they choose 'First' again, it changes back to 'Choose Anything'.

Note that ``data-help`` directives will override the help text provided in the attribute definition, and like
``data-label``, any options that do not have a ``data-help`` directive will not change the help text from it's
last value. This means that if we moved the 'Choose Anything' help text to the definition of ``hard_choice``,
and left the ``First`` option without a directive, we would see the same 'Choose Anything' help text at the
start, but if you selected 'Second' and switch back to 'First', the help text will still read 'Choose No'.


Dynamic Min and Maxes
*********************
Expand Down
11 changes: 11 additions & 0 deletions source/release-notes/v4.1-release-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ Forms, Widgets, and User Input
* Smart attributes
* Form YAML stuff

New data-help Directive
.......................

Version 4.1 adds the ``data-help`` directive, allowing you to dynamically change
the help text below form items when certain select options are chosen. For example,
you may have a ``node_type`` select widget, where type ``basic`` has older GPUs than
``advanced``. The ``data-help`` directive can change the help text on the ``num_gpus``
option for users who select ``advanced`` so that they can take that info into account
when deciding how many GPUs to select. For full documentation, see :ref: `dynamic-bc-apps-data-help`.


Files, Projects, and Data Management
------------------------------------
* Files App
Expand Down