Richard
Richard

Reputation: 1

OpenTBS - checking against individual options in a checkbox field to insert conditional content per option

In an OpenTBS situation, I'm trying to use conditional blocks to check against each individual option/answer that a user selects in a checkbox field in a form whose data is being used to insert the conditional content.

I've asked you about this previously, here Can a 'when' conditional section show content based on a 'contains' or 'includes' parameter? , and you kindly gave me a suggested solution.

Unfortunately my developers could not get it working. I wonder if there's another way. For example, can one target a specific checkbox option in a checkbox field to query whether it is checked or unchecked, using a conditional block?

Let's say I have this checkbox field in my form:

Select the kinds of personal information you collect

Is it possible to target each choice individually with a conditional block, to check whether it has been checked/selected or not, e.g., along these lines:

[onshow;block=begin;enlarge=tbs:p;when [var.Select the kinds of personal information you collect_Name]=!'']

Name

[onshow;block=end;enlarge=tbs:p]

If this is possible, I could insert conditional content per selected option, regardless of whether other options are also selected.

Any help much appreciated. Thanks very much.

Richard

Upvotes: 0

Views: 180

Answers (1)

Skrol29
Skrol29

Reputation: 5552

It it possible and simple to use conditional blocks on paragraphs.

Here is 3 comments about your snippet :

  1. It is unwise to use block=begin and block=end in a DOCX (or other XML based documents) because we are note sure they are placed in symmetric positions relatively to the to the inner XML. It's true you are also using parameter enlarge, but there is much more simple (see below).
  2. It is good to protect the when string expression against quotes, using strconv=esc.

So a simple solution could be:

PHP :

global $collect_name, $collect_adress, $collect_phone;
$collect_name = ...;
$collect_adress= ...;
$collect_phone= ...;

DOCX :

  • [onshow;block=tbs:p;when '[var.collect_name;strconv=esc]'=!''] Name
  • [onshow;block=tbs:p;when '[var.collect_adress;strconv=esc]'=!''] Address
  • [onshow;block=tbs:p;when '[var.collect_phone;strconv=esc]'=!''] Phone

Upvotes: 0

Related Questions