Checkboxes in Advance PDF’s can be quite tricky, you might experience the following issues:
- Checkbox not setting as checked.
- Cannot display the label of the checkbox in the same line.
How to mark a checkbox as checked with an if statement:
In the following piece of code, I am marking the checkbox based on the approval status field of the Sales Order, if it is equal to pending approval I will mark the checkbox as true.
<input type=”checkbox” id=”approvalstatus” name=”approvalstatus” value=”1″ checked=”${(orderstatus== ‘Pending Approval’)?string(‘true’, ‘false’)}” style=”inline-block;” display=”inline”/><label for=”carrier”> Pending Approval</label>
Newer version of freemarker use: checked=”${(orderstatus== ‘Pending Approval’)?c}”
If your checkbox isn’t set to true or false ensure that you do not have duplicate IDs and names in the same HTML structure.
To put your label and the checkbox in the same line, add the following code to the input checkbox tag: style=”inline-block;” display=”inline” review the sample code above.
0 Comments