TinyButStrong - the PHP Template Engine
Categories > OpenTBS with ODT >

Problem adding a checkbox in a table

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs

By: ludovic
Date: 2016-06-15
Time: 18:22

Problem adding a checkbox in a table

Hi,

I want to add a checkbox in a table, one checkbox by row.
In my template, I have a single row table with two column:
the checkbox with, in additional information, [parts.checked;att=form:current-state]   |  [parts.name;block=tbs:row]

In the php side, the variable checked can be set to 'checked' or 'unchecked' .

On the merged document, all the rows are generated but each checkbox is, in fact, the same "instance" of an unique checkbox. I mean, in the merged document, if I check one checkbox, all of the checkboxes are checked. So, obviously, the checkboxes are not correctly set on the merged document.

Did I miss something in the template?

Thanks in advance.
By: Skrol29
Date: 2016-06-16
Time: 14:59

Re: Problem adding a checkbox in a table

Hi Ludovic,

The form control you are placing in your template is a <draw:control> element which is linked to a separated <form:checkbox> element by attribute « draw:control="my_control" ».
So when the table is merged, the <draw:control> element is multiplicated but unfortunately all copies refer to the same <form:checkbox>.

I don't know how to solve this for now.
By: ludovic
Date: 2016-06-16
Time: 15:18

Re: Problem adding a checkbox in a table

Hi Skrol29,

Thank you for your answer.
You are right. This is exactly what is happening. I saw what you are describing in the xml file of the merged document.

I am still looking for how to solve this issue...
By: Skrol29
Date: 2016-06-16
Time: 15:49

Re: Problem adding a checkbox in a table

Here is a solution (not tested yet) :

1) Delete your TBS field « [parts.checked;att=form:current-state] ».

2) In the property Description of the check-box item, add the TBS field: « [parts.#;att=draw:control#draw:control;ope=msk:tbs-checkbox-*] ».
Property Help is linked to the <draw:control> element.

3) In the property Help of the check-box control, add the TBS field: « [parts2.#;block=form:checkbox;att=form:checkbox#form:id;ope=msk:tbs-checkbox-*] ».
Property Help is linked to the <form:checkbox> element.

4) At the PHP script, replace  $TBS->MergeBlock('parts', ...) with $TBS->MergeBlock('parts,parts2', ...)
This will merge the two block 'part' and 'part2' with the same data.




By: ludovic
Date: 2016-06-16
Time: 19:56

Re: Problem adding a checkbox in a table

Thank you for your solution ! I did not succeed to have it working but you show the way to follow !

What I did:
In the property Help of the checkbox, I put : [parts2.cpt;block=form:checkbox;att=form:checkbox#xml:id;ope=msk:tbs-checkbox-*]
And just after the checkbox, in the template, I put: [parts.cpt;att=draw:control#draw:control;ope=msk:tbs-checkbox-*]

The key here is to use xml:id instead of form:id, because the draw element refers to the checkbox using the

With this, in the merged document, each checkbox in independent of the other ones. I can manually check or uncheck each checkbox individually !

But now, I need to check the checkbox using openTBS.
So I put [registration_parts.received;att=form:current-state] in the property additional info of the checkbox but it does not work.

I am still investigating... but again, thank you so much !
By: ludovic
Date: 2016-06-17
Time: 16:14

Re: Problem adding a checkbox in a table

I got it !

The solution to check the checboxes was to add this in additional information :
[parts2.checked;att=form:current-state;ope=msk:*]

I think the clue is to have the aame data array in the additional information and in the help property, in my case parts2