> For the complete documentation index, see [llms.txt](https://64j.gitbook.io/multifields-2/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://64j.gitbook.io/multifields-2/tipy-i-parametry/table.md).

# table

![](/files/-MITb_TXQ6kJyfO153cU)

![](/files/-MITbdFayu6FU7YEoBet)

Для построения таблицы требуются все элементы, так же как и в html.

`type => table`\
&#x20; `type => table:head`\
&#x20;   `type => table:row`\
&#x20;     `type => table:th`\
&#x20; `type => table:body`\
&#x20;   `type => table:row`\
&#x20;     `type => table:td`

При использовании элемента **table:head** добавляется возможность добавления или удаления колонок в таблице. Так же можно выбрать и тип данных. При добавлении новой колонки, параметры tpl и prepare берутся из первой колонки в таблице.

Пример

```php
<?php

return [
    'settings' => [],
    'templates' => [
        'TableWithHead' => [
            'type' => 'table',
            'placeholder' => 'Table title',
            'value' => true,
            'items' => [
                'thead' => [
                    'type' => 'table:head',
                    'items' => [
                        'row' => [
                            'type' => 'table:row',
                            'items' => [
                                [
                                    'type' => 'table:th',
                                    'items' => [
                                        [
                                            'type' => 'id',
                                            'value' => 'id'
                                        ]
                                    ],
                                    'tpl' => '@CODE:<th>[+mf.items+]</th>'
                                ],
                                [
                                    'type' => 'table:th',
                                    'items' => [
                                        [
                                            'type' => 'text',
                                            'value' => 'Title'
                                        ]
                                    ],
                                    'tpl' => '@CODE:<th>[+mf.items+]</th>'
                                ],
                                [
                                    'type' => 'table:th',
                                    'items' => [
                                        [
                                            'type' => 'text',
                                            'value' => 'Text'
                                        ]
                                    ],
                                    'tpl' => '@CODE:<th>[+mf.items+]</th>'
                                ],
                                [
                                    'type' => 'table:th',
                                    'items' => [
                                        [
                                            'type' => 'date',
                                            'value' => 'Date'
                                        ]
                                    ],
                                    'tpl' => '@CODE:<th>[+mf.items+]</th>'
                                ],
                                [
                                    'type' => 'table:th',
                                    'items' => [
                                        [
                                            'type' => 'image',
                                            'value' => 'Image'
                                        ]
                                    ],
                                    'tpl' => '@CODE:<th>[+mf.items+]</th>'
                                ]
                            ],
                            'tpl' => '@CODE:<tr>[+mf.items+]</tr>'
                        ]
                    ],
                    'tpl' => '@CODE:<thead class="thead-dark">[+mf.items+]</thead>'
                ],
                'tbody' => [
                    'type' => 'table:body',
                    'items' => [
                        'row' => [
                            'type' => 'table:row',
                            'items' => [
                                [
                                    'type' => 'table:td',
                                    'items' => [
                                        [
                                            'type' => 'id'
                                        ]
                                    ],
                                    'tpl' => '@CODE:<td>[+mf.items+]</td>'
                                ],
                                [
                                    'type' => 'table:td',
                                    'items' => [
                                        [
                                            'type' => 'text'
                                        ]
                                    ],
                                    'tpl' => '@CODE:<td>[+mf.items+]</td>'
                                ],
                                [
                                    'type' => 'table:td',
                                    'items' => [
                                        [
                                            'type' => 'text'
                                        ]
                                    ],
                                    'tpl' => '@CODE:<td>[+mf.items+]</td>'
                                ],
                                [
                                    'type' => 'table:td',
                                    'items' => [
                                        [
                                            'type' => 'date'
                                        ]
                                    ],
                                    'tpl' => '@CODE:<td>[+mf.items+]</td>'
                                ],
                                [
                                    'type' => 'table:td',
                                    'items' => [
                                        [
                                            'type' => 'image'
                                        ]
                                    ],
                                    'tpl' => '@CODE:<td>[+mf.items+]</td>'
                                ]
                            ],
                            'tpl' => '@CODE:<tr>[+mf.items+]</tr>'
                        ]
                    ],
                    'tpl' => '@CODE:<tbody>[+mf.items+]</tbody>'
                ]
            ],
            'tpl' => '@CODE:<table class="table table-sm table-hover table-bordered">[+mf.items+]</table>'
        ],

        'Table' => [
            'type' => 'table',
            'title' => 'Table',
            'placeholder' => 'Table 1 title',
            'value' => false,
            'items' => [
                'tbody' => [
                    'type' => 'table:body',
                    'items' => [
                        'row' => [
                            'type' => 'table:row',
                            'items' => [
                                [
                                    'type' => 'table:td',
                                    'items' => [
                                        [
                                            'type' => 'id',
                                            'placeholder' => 'id'
                                        ]
                                    ],
                                    'tpl' => '@CODE:<td>[+mf.items+]</td>'
                                ],
                                [
                                    'type' => 'table:td',
                                    'items' => [
                                        [
                                            'type' => 'text',
                                            'placeholder' => 'Title'
                                        ]
                                    ],
                                    'tpl' => '@CODE:<td>[+mf.items+]</td>'
                                ],
                                [
                                    'type' => 'table:td',
                                    'items' => [
                                        [
                                            'type' => 'text',
                                            'placeholder' => 'Title'
                                        ]
                                    ],
                                    'tpl' => '@CODE:<td>[+mf.items+]</td>'
                                ],
                                [
                                    'type' => 'table:td',
                                    'items' => [
                                        [
                                            'type' => 'date',
                                            'placeholder' => 'Date'
                                        ]
                                    ],
                                    'tpl' => '@CODE:<td>[+mf.items+]</td>'
                                ],
                                [
                                    'type' => 'table:td',
                                    'items' => [
                                        [
                                            'type' => 'image',
                                            'placeholder' => 'Image'
                                        ]
                                    ],
                                    'tpl' => '@CODE:<td>[+mf.items+]</td>'
                                ]
                            ],
                            'tpl' => '@CODE:<tr>[+mf.items+]</tr>'
                        ]
                    ],
                    'tpl' => '@CODE:<tbody>[+mf.items+]</tbody>'
                ]
            ],
            'tpl' => '@CODE:<table class="table table-sm table-hover table-bordered">[+mf.items+]</table>'
        ]
    ]
];
```
