使用 Symfony 单击后更改 link 的状态

change the state of a link after a click with Symfony

大家好,我遇到了困难,我有一个页面显示所有可用联合养老保险的列表,并带有一个参与按钮,可以在此处发送请求我希望一旦我们点击参与,我们将不再有可能点击它谢谢

mon fichier twig “' {% for tont in tontines %}

<tr class="active">
<td>{{ tont.nomTontine }}</td>>
<td>{{ tont.descriptionTontine }}</td>
<td>{{ tont.dateDebut.format("d/m/Y") }}</td>
<td>{{ tont.dureeCouverte.format("d/m/Y") }}</td>
<td>{{ tont.montantPart }}fcfa</td>
<td>{{ tont.periodicite }}</td>
<td>{{ tont.createdAt.format("d/m/Y")}}</td>
{% for user in user %}
{% if tont.usersId== user.id %}
<td>{{ user.prenom }} {{ user.nom }}</td>
{% endif %}
{% endfor %}
    {% for part in part %}
    {% if part.nomTontine== tont.nomTontine and part.idUtilisateur %}
        <td><h6 class="btn btn-primary">Déjà demandé</h6></td>
    {% else %}
    <td> <a href="{{ path('participant' , {nomTontine: tont.nomTontine , usersId: tont.usersId}) }}" class="btn btn-info">Participer</a> </td>
    {% endif %}
    {% endif %}
{% endfor %} '"

您可以将信息存储在数据库中 具有属性的实体:

  • 按钮name:string
  • isClickedBy:用户[]

然后您需要一个逻辑,检查经过身份验证的用户是否在 isClickedBy 数组中。

如果您还需要来自用户对象的信息,则需要一对多关系。