# 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>'
        ]
    ]
];
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://64j.gitbook.io/multifields-2/tipy-i-parametry/table.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
