根据无线电元素的选定选项打印表

发布于 2025-01-30 04:26:04 字数 2607 浏览 1 评论 0原文

我有一个带有三个选项的无线电元件(正常时间敏感,并且保持拾音)。每当用户单击一个选项时,该选项的唯一表元素(供用户填写信息)会自动弹出。最后,我想将所有提交的数据打印到PDF附件。

当我为其编写树枝代码时,我被困在要打印属于所选选项的表的部分中,

{# choose_your_shipping_option: radio's key  #}
{# Normal: option text #}
{% if webform_token('[webform_submission:values:choose_your_shipping_option]') == "Normal" %}
<table>
    <tr>
        <th>Shipping Address:</th>
        <th>Acct #</th>
    </tr>
    <tr>
        <td rowspan="3">[webform_submission:values:shipping_address]</td>
        <td>[webform_submission:values:id_num]</td>
    </tr>
    <tr>
        <th>Phone</th>
    </tr>
    <tr>
        <td>
            [webform_submission:values:phone]
        </td>
    </tr>
</table>
{% elseif webform_token('[webform_submission:values:choose_your_shipping_option]') == "Time Sensitive" %}

<table>
    <tr>
        <th>Delivery Date</th>
        <td>[webform_submission:values:time_sensitive_01_delivery_date]</td>
        <th>Must Have Street Address (No PO Box)</th>
    </tr>
    <tr>
        <th colspan="2">Shipping Address:</th>
        <th>Acct #</th>
    </tr>
    <tr>
        <td colspan="2" rowspan="3" style="text-align: center;">[webform_submission:values:shipping_address_2]</td>
        <td>[webform_submission:values:id_num]</td>
    </tr>
    <tr>
        <th>Phone</th>
    </tr>
    <tr>
        <td>
            [webform_submission:values:phone_2]
        </td>
    </tr>
</table>
{% elseif webform_token('[webform_submission:values:choose_your_shipping_option]') == "Hold For Pick-Up" %}

<table>
    <tr>
        <th>Will be picked up by</th>
        <th>Pick-up Date:</th>
    </tr>
    <tr>
        <td>[webform_submission:values:pick_up_01_picked_up_by]</td>
        <td>[webform_submission:values:pick_up_01_pick_up_date]</td>
    </tr>
    <tr>
        <th>Pick-up Location</th>
        <th>Pick-up Time</th>
    </tr>
    <tr>
        <td>[webform_submission:values:location]</td>
        <td>[webform_submission:values:time]</td>
    </tr>
</table>

{% endif %}

当我使用 webform_token 时,它将破坏PDF模板。是否有正确的方法仅打印用户填写的方法?

I have a radio element with three options (Normal, Time Sensitive, and Hold For Pick-Up). Every time an user clicks an option, an unique table element for the option (for user to fill information) will pop up automatically. Finally, I would like to print all the submitted data to PDF attachment.

As I write the twig code for it, I am stuck in the part where I want to print the table that belongs to the selected option

{# choose_your_shipping_option: radio's key  #}
{# Normal: option text #}
{% if webform_token('[webform_submission:values:choose_your_shipping_option]') == "Normal" %}
<table>
    <tr>
        <th>Shipping Address:</th>
        <th>Acct #</th>
    </tr>
    <tr>
        <td rowspan="3">[webform_submission:values:shipping_address]</td>
        <td>[webform_submission:values:id_num]</td>
    </tr>
    <tr>
        <th>Phone</th>
    </tr>
    <tr>
        <td>
            [webform_submission:values:phone]
        </td>
    </tr>
</table>
{% elseif webform_token('[webform_submission:values:choose_your_shipping_option]') == "Time Sensitive" %}

<table>
    <tr>
        <th>Delivery Date</th>
        <td>[webform_submission:values:time_sensitive_01_delivery_date]</td>
        <th>Must Have Street Address (No PO Box)</th>
    </tr>
    <tr>
        <th colspan="2">Shipping Address:</th>
        <th>Acct #</th>
    </tr>
    <tr>
        <td colspan="2" rowspan="3" style="text-align: center;">[webform_submission:values:shipping_address_2]</td>
        <td>[webform_submission:values:id_num]</td>
    </tr>
    <tr>
        <th>Phone</th>
    </tr>
    <tr>
        <td>
            [webform_submission:values:phone_2]
        </td>
    </tr>
</table>
{% elseif webform_token('[webform_submission:values:choose_your_shipping_option]') == "Hold For Pick-Up" %}

<table>
    <tr>
        <th>Will be picked up by</th>
        <th>Pick-up Date:</th>
    </tr>
    <tr>
        <td>[webform_submission:values:pick_up_01_picked_up_by]</td>
        <td>[webform_submission:values:pick_up_01_pick_up_date]</td>
    </tr>
    <tr>
        <th>Pick-up Location</th>
        <th>Pick-up Time</th>
    </tr>
    <tr>
        <td>[webform_submission:values:location]</td>
        <td>[webform_submission:values:time]</td>
    </tr>
</table>

{% endif %}

It would ruin the pdf template when I use webform_token. Is there a correct way to print only the one that's filled by the user?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文