0

I'm trying to show exit button on every question along with the continue button in docassemble. Continue button is generated by default by docassemble but I want to have the exit button too. I'm aware that it's not possible to have more than one directives with a question but I'm wondering if there's a trick to do it somehow. I've gone through the docs and didn't find anything that could work to show the exit button.

Is it possible?

Magnetron
  • 7,495
  • 1
  • 25
  • 41

1 Answers1

0

You could use action buttons, but you would need to add it to each question in the YAML. There is no feature for adding additional buttons to every screen in an interview.

code: |
  exit_button = [{'action': 'https://docassemble.org', 'label': 'Exit', 'icon': 'sign-out-alt', 'color': 'danger'}]
---
mandatory: True
question: |
  Do you like fruit?
yesno: likes_fruit
action buttons:
  code: exit_button
---
mandatory: True
question: |
  Do you like vegetables?
yesno: likes_vegetables
action buttons:
  code: exit_button
---
mandatory: True
question: |
  What is your favorite color?
fields:
  - Color: favorite_color
action buttons:
  code: exit_button
---
mandatory: True
question: Done
action buttons:
  code: exit_button

Alternatively, you could create a JavaScript file in the static folder, include it in your interview with features -> javascript, and in the JavaScript file you could add a daPageLoad listener that adds a button to the button <div> (which you can find at fieldset.da-button-set).

Jonathan Pyle
  • 340
  • 1
  • 4
  • Thank you so much for the solution! I implemented your solution for exit button using action buttons. Now I'm want to add a restart button too along with continue and exit buttons. I've tried various methods but I'm unable to implement it properly. Your help would be much appreciated! – Fumikage Tokoyami Oct 13 '22 at 07:30
  • This will add a restart button: `exit_button = [{'action': 'https://docassemble.org', 'label': 'Exit', 'icon': 'sign-out-alt', 'color': 'danger'}, {'action': '?reset=1', 'label': 'Restart', 'icon': 'undo', 'color': 'warning'}]` – Jonathan Pyle Oct 14 '22 at 10:24