【发布时间】:2018-11-12 19:29:19
【问题描述】:
也许有人可以帮助我,因为我一周以来一直在挖掘论坛和文档,如何呈现一个表格,其中我在第 3 列中有一个表格。
我有一个带有以下 sn-p 的 CollectionController 类:
return $this->render(
'vollmachtapp/pages/collections/list2.html.twig',
[
'attachmentForm' => $attachmentForm->createView(),
'list' => $apiClient->listAllVollmachten()
]
);
附件表格如下所示:
$attachmentForm = $this->createForm( SimpleAttachmentType::class, $attachment );
这是我的 SimpleAttachmentType:
class SimpleAttachmentType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('file', FileType::class)
->add('vollmachtId', HiddenType::class)
->add('save', SubmitType::class, ['label' => 'Vollmacht hochladen']);
}
}
现在我使用的树枝看起来像:
<table id="datatable" class="table table-striped table-bordered">
<thead>
<tr>
<th>Vollmacht ID</th>
<th>Users</th>
<th>Upload/Download</th>
</tr>
</thead>
<tbody>
{% for collection in list.items %}
<tr>
<td>{{ collection.id }}</td>
<td>
{% for user in collection.users %}
<a href="{{ url('user_detail', {'id': user.id}) }}">
{{ user.name }}
</a><br>
{% endfor %}
</td>
<td>
<a href="{{ url('downloadVollmacht', {'id': user.id}) }}"><button type="button" class="btn btn-sm btn-primary">Download Vollmacht</button></a>
{% if(app.user.role == "admin") %}
<hr>
<div class="text-center mtop20">
{{ form_start(attachmentForm, {method: 'POST'}) }}
{% if not attachmentForm.vars.valid %}
<div class="alert alert-danger alert-dismissible fade in" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
{{ form_errors(attachmentForm.file) }}
</div>
{% endif %}
{{ form_widget(attachmentForm.vollmachtId, {'name': vollmachtId, 'value': collection.id}) }}
{{ form_widget(attachmentForm.file) }}
<br />
{{ form_widget(attachmentForm.save, {attr: {'class': 'btn-left btn btn-sm btn-primary'}}) }}
{{ form_end(attachmentForm) }}
</div>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
我遇到的问题,表格只呈现在表格的第一行。谁能告诉我我做错了什么并且必须进行更改才能使其正常工作?
感谢和最好的问候, 迈克尔·奥布斯特
【问题讨论】:
标签: php forms symfony html-table