docassemble icon indicating copy to clipboard operation
docassemble copied to clipboard

show if, enable if cannot access variables from preliminary questions?

Open spaeth opened this issue 4 years ago • 3 comments

Hello to all,

I have come across a strange behavior with field conditions in version 1.3.5 and hope someone can help me. I would expect that with the following code, the two fields are editable as soon as I select "Show field on page 2" in the first question. But the selection doesn't matter, only the "field 2" is always shown activated.

  ---
  mandatory: True
  code: |
    page1
    page2
  ---
  question: |
    Show Uploads?
  fields:   
    - Show field on page 2?: is_show
      datatype: yesno
  continue button field: page1
  ---
  question: |
    is_show: ${ is_show }
  fields:
    - Field 1: field_1
      show if: is_show
    - Field 2: field_2
      enable if: is_show
  continue button field: page2
  ---

A workaround is to include the is_show field on question page 2 as well, then the behavior is as expected, but I don't really want that.

Regards

Thomas

spaeth avatar Nov 22 '21 10:11 spaeth

I am running into a similar issue. I will try to show my code in a bit.

raulvasquez avatar Dec 02 '21 20:12 raulvasquez

See https://docassemble.org/docs/fields.html#show%20if and use the code variant of show if if you want to refer to an already-defined Python variable rather than a field in the front end.

jhpyle avatar Dec 03 '21 13:12 jhpyle

I almost missed the answer. Thank you very much.

spaeth avatar Jan 24 '22 11:01 spaeth