data-table-bundle icon indicating copy to clipboard operation
data-table-bundle copied to clipboard

Feature request: data_table_theme twig token

Open bdecarne opened this issue 1 year ago • 1 comments

Create a data_table_theme token like the form_theme token (https://symfony.com/doc/current/form/form_themes.html#applying-themes-to-single-forms).

This would make it possible to define custom theme blocks limited to one table.

Exemple :

{% data_table_theme products _self %}

{% block content %}
    <div class="container-fluid">
        {{ data_table(products) }}
    </div>
{% endblock %}

{% block column_phone_number_value %}
    specific theme
{% endblock %}

PS: awesome work !

bdecarne avatar Jan 30 '24 14:01 bdecarne

Hey. Thanks for the suggestion. The rendering process of this bundle is much simpler than in forms, and it should be easy to implement, by simply updating the themes key in the vars array of the DataTableView.

PS: awesome work !

Thank you! :)

Kreyu avatar Feb 08 '24 21:02 Kreyu

I've implemented the Twig token and merged. It will be included in the next release.

Similar to forms, you can set the data table themes directly in the Twig template, by using the data_table_theme tag:

{% data_table_theme products 'themes/data_table.html.twig' %}

{{ data_table(products) }}

If you wish to use multiple themes, pass an array using the with keyword:

{% data_table_theme products with [
    'themes/data_table.html.twig', 
    '@KreyuDataTable/themes/bootstrap_5.html.twig',
] %}

{{ data_table(products) }}

If you wish to disable currently configured themes for the data table and only use given ones, add the only keyword after the list of data table themes:

{% data_table_theme products with ['themes/data_table.html.twig'] only %}

{{ data_table(products) }}

Kreyu avatar Jun 28 '24 11:06 Kreyu

Available in 0.18.0

Kreyu avatar Jun 28 '24 11:06 Kreyu