Have a question with regard to this code. It works (on the basis of a couple of questions, you can go from input to output with a minimum of code. Do you see problems with this approach (want to know this before I implement it accross different templates). Thanks!
{% comment %}Geef vragen in (evt dynamisch via result-tag{% endcomment %}
{% stripnewlines %}
{% assign
arr_Serie1_StandardTasks_Descriptions
=
"
Inboeken van de boekhoudkundige documenten.
|
Bijstand bij opmaak en indiening van de BTW -aangifte.
|
Voorbereiding en indiening van de aangifte bedrijfsvoorheffing.
|
Contacten met de bank.
|
Betaling van de leveranciersfacturen.
|
Betaling van de lonen.
|
Opvolging van openstaande klanten.
|
Opstellen van een maandelijkse of trimestriƫle rapportering en bespreking.
|
Opstellen van prognoses die maandelijks of trimestrieel worden aangepast."
| split:"|"
%}
{% endstripnewlines %}
{% comment %}Stel output op{% endcomment %}
{% stripnewlines %}
{% for task in arr_Serie1_StandardTasks_Descriptions %}
{% ic %}
{% newline %}
- {% input custom.arr_Serie1_StandardTasks_Checkbox[forloop.index0] as:boolean default:false %} {{arr_Serie1_StandardTasks_Descriptions[forloop.index0] | strip}}
{% endic %}
{% if custom.arr_Serie1_StandardTasks_Checkbox[forloop.index0] == 'true' %}
{% nic %}
{% newline %}- {{arr_Serie1_StandardTasks_Descriptions[forloop.index0] | strip}}
{% endnic %}
{% endif %}
{% endfor %}
{% endstripnewlines %}
@Bart_Verhaeghe, really like what you did there! Combine an array with a list of booleansā¦
I wouldāve done this though :
{% assign arr_Serie1_StandardTasks_Descriptions = "Inboeken van de boekhoudkundige documenten.|Bijstand bij opmaak en indiening van de BTW -aangifte.|Voorbereiding en indiening van de aangifte bedrijfsvoorheffing.|Contacten met de bank.|Betaling van de leveranciersfacturen.|Betaling van de lonen.|Opvolging van openstaande klanten.|Opstellen van een maandelijkse of trimestriƫle rapportering en bespreking.|Opstellen van prognoses die maandelijks of trimestrieel worden aangepast." | split:"|" %}
So you didnāt need to bother to strip the new lines and all, but other than that:
Also, another thing I learned, is to use a second array to use as an unique key.
Why? You donāt want to find a type in your questions sometime in the future where you want to change that typo. When changing that typo, your āuniqueā input object will disappear (because the name of that object changes).
See also:
Another related question though: Iād like to compose the array with the unique keys on the basis of the original array āarr_Serie1_StandardTasks_Descriptionsā.
So the array with should be something like āStandardTask_Opt0|StandardTask_Opt1|StandardTask_Opt2ā with the number running from 0 to the size of the array āarr_Serie1_StandardTasks_Descriptionsā. What would be the easiest way to achieve this?
You could create a second array based on the first: if you loop over that first array, and in each loop you create a variable where a fixed name is made, append it with a number and a ā;ā. That variable can then be used to create the second array.
But, the reason I donāt post an example of this code, is because you can always screw up things if you add a new part into your first array. Itāll affect the second array and a key like ākey_5ā (where this key was in the 5th loop for instance) can become ākey_6ā all of a sudden, simply because you added a new part before the 5th part.
Thatās why Iād suggest doing it manually with some unique words and/or numbers for each part of your first array. Manually to do, I know, but it canāt be done all automatically. Like your thinking though
The code can be written a little bit shorter.
Iād do it like this:
{% comment %}Geef vragen in (evt dynamisch via result-tag{% endcomment %}
{% stripnewlines %}
{% assign
arr_Serie1_StandardTasks_Descriptions
= "
Inboeken van de boekhoudkundige documenten.|
Bijstand bij opmaak en indiening van de BTW -aangifte.|
Voorbereiding en indiening van de aangifte bedrijfsvoorheffing.|
Contacten met de bank.|
Betaling van de leveranciersfacturen.|
Betaling van de lonen.|
Opvolging van openstaande klanten.|
Opstellen van een maandelijkse of trimestriƫle rapportering en bespreking.|
Opstellen van prognoses die maandelijks of trimestrieel worden aangepast." | split:"|"
%}
{% endstripnewlines %}
{% comment %}Stel output op{% endcomment %}
{% stripnewlines %}
{% for task in arr_Serie1_StandardTasks_Descriptions %}
{% newline %}
{% ifi custom.arr_Serie1_StandardTasks_Checkbox[forloop.index0] == 'true' %}{% nic %}- {% endnic %}{% input custom.arr_Serie1_StandardTasks_Checkbox[forloop.index0] as:boolean default:false %} {{arr_Serie1_StandardTasks_Descriptions[forloop.index0] | strip}}
{% endifi %}
{% endfor %}
{% endstripnewlines %}
Escpecially the last part with the ifi is interesting
Just tested this and the Svenās remarks are still valid (eg if you mark the first three options to āyesā, and then ādeleteā the second option afterwards, the booleans āchangeā).