Hi @lieels01
thanks for the code!
I had a look and if I understand correctly, I think this is what you need to add:
- To add the text + new input to the list of attendees
You would print this right after the name ( {{ name }} ), probably only if the boolean is ticked.
If you also want to print it when the boolean is not ticked, you’d have to include it in the “else” part of this if-statement as well.
{% ic %}{::infotext}{% input custom.represented.selection as:boolean %}Vertegenwoordigd{:/infotext}{% endic %}
{% if custom.represented.selection == true %}
{% stripnewlines %}
|_Vertegenwoordigd:_ {{ warning_representant }}
{% endstripnewlines %}
{% unless show_no_options %}
{% fori name in zkv_names %}
{% capture name_id %}{{ name | replace: '.','' | replace: ' ','' | remove:'-' }}{% endcapture %}
{% ic %}{% input period.custom.[name_id].attendance_represent as:boolean default:true %}{% endic %}{% assign name_attendance_represent = period.custom.[name_id].attendance_represent | default:true %}{% if name_attendance_represent %}{% nic %}*{% endnic %}{{ name }} vertegenwoordigd door {% input custom.text.name_rep.name placeholder:"Naam" %}{% else %}{% assign not_all_present = true %}{% ic %}*{{ name }}*{% endic %}{% capture not_present_var %}not_present_{{ forloop.index }}{% endcapture %}{% assign [not_present_var] = name %}{% endif %}
{% endfori %}
{% endunless %}
{% endif %}
- Have the text + name from the input also in the signatures.
This part is a bit more tricky, because you’re printing the signature from the collection zkv_signatures
You need to trace back where this collection gets populated.
Since it’s not visible in the code you shared here, I took the liberty of taking a peek at the full template in your SF environment
You’ll need to add it here:
{% if person.custom.represented_by_name != blank and type == "legal" %}
{% assign names = names | append:" met als vaste vertegenwoordiger " | append:person.custom.represented_by_name %}
{% assign signatures = signatures | append:"<br>" | append:"met als vaste vertegenwoordiger " | append:person.custom.represented_by_name %}
which will now become:
{% capture name_id %}{{ person.name | replace: '.','' | replace: ' ','' | remove:'-' }}{% endcapture %}
{% if person.custom.represented_by_name != blank and type == "legal" %}
{% assign names = names | append:" met als vaste vertegenwoordiger " | append:person.custom.represented_by_name %}
{% assign signatures = signatures | append:"<br>" | append:"met als vaste vertegenwoordiger " | append:person.custom.represented_by_name %}
{% elsif period.custom.[name_id].attendance_represent != false and custom.text.name_rep.name != blank %}
{% assign signatures = signatures | append:"<br>" | append:"vertegenwoordigd door " | append:custom.text.name_rep.name %}
{% endif %}
So, first you need the name_id, otherwise we can’t access the value of the boolean.
Then you can add an elsif statement, that in case there isn’t a fixed representative, will look whether a representative was filled out in this template.
And then you add the name to the signature in case one has been filled out.
You could also flip this logic around and make the new code the if-condition and the existing code the elsif-condition, depending on how you want it to function.
I have two remarks though.
Firstly, with the current setup you’ll only be able to define one representative because the input field is not tied to anything. Instead it would make sense to tie it to the boolean of the person being represented, so name it something like this:
e.g. period.custom.[name_id].rep_name
Secondly, this name_id isn’t the best approach to store data. You can run into issues when names contain special characters for example. If this code isn’t in use already, I’d recommend changing it. Looping over the people drop instead and using the persistent_id is the preferred way to tie custom data to people.
Hope this was useful,
Kind regards,
Romy