forms - 将 symfony2 表单标签制作成链接

标签 forms symfony

我正在尝试勾选“使用条款”。这是我到目前为止所做的:

->add('terms', 'checkbox', array(
            'mapped' => false,
            'required' => false,
            'label' => "J'accepte les Conditions Générales de Vente et les Conditions
                        Générales d'Utilisation",
            'attr' => array('style' => 'margin-left:-257px;'),
            'constraints' => new True(array('message' => "SVP acceptez les Conditions 
                                                          Générales de Vente et
                                                          les Conditions Générales
                                                          d'Utilisation")),
                ))

我想制作 label 的“Conditions Générales de Vente”部分作为 PDF 文件的链接供用户阅读。

当用户单击该链接时,Ajax 函数将调用将呈现 PDF 的 Controller 。

我只是不知道如何添加 <a></a>label里面.

最佳答案

这个问题很老,但可能对 future 的访问者有所帮助。我找到了另一种在标签内生成链接的简单方法:

 //Set the links as variables
 {% set terms %}
   <a href="{{ path('terms_conditions') }}">terms &amp;conditions</a>
 {% endset %}
 {% set policy %}
     <a href="{{ path('privacy_policy') }}">privacy policy</a>
 {% endset %}

 //display the form and use the variables inside the label
 {{ form_start(paymentForm) }}
 {{ form_widget(paymentForm) }}
 <label for="transaction_terms">I have read and accept the {{ terms }} and {{ policy }}.</label>
 {{ form_end(paymentForm) }}

关于forms - 将 symfony2 表单标签制作成链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32910479/

相关文章:

jquery - 在提交表单时调用js函数并阻止ajax请求完成后提交表单

php - 使用 assetic 提供相关图像

php - 如何使用Symfony Mailer组件禁用 "verify_peer"?

sql - 如何在查询中使用 "case when"

jquery - .parent().remove() 问题

JavaScript 数组到 ColdFusion

php - 如何在当前页面上显示 PHP 重复条目错误消息

forms - JSF 生命周期的不同阶段在包含表单的无状态 View 中如何表现

php - Doctrine entitymanager clear 不完全清楚

symfony - 如何将 token 存储作为参数传递给 Symfony 3.4 中的事件监听器