philiplb / CRUDlex

CRUDlex is an easy to use CRUD generator for Symfony 4 and Silex 2 which is great for auto generated admin pages
https://philiplb.de/crudlex/
MIT License
109 stars 23 forks source link

Array to String error when filtering by reference type and navigating to next page #100

Closed planeth44 closed 6 years ago

planeth44 commented 6 years ago

Let's say I have a table produit and one field in the table is a reference to another table client.

On the productList page, I filter by the client_id field. The result gives me 2 pages. If I navigate to the page 2, the error occurs.

This the DBALException message:

An exception occurred while executing 'SELECT COUNT(id) FROM `produit` `produit` WHERE (`id_client` = ?) AND (deleted_at IS NULL)' with params [{"id":<UUID>"}]:

Notice: Array to string conversion

The URL of the page: crud/produit?crudPage=1&crudSortField=created_at&crudSortAscending=true&crudFilterid_client%5Bid%5D=<UUID>

philiplb commented 6 years ago

Ou, good find. Thx for the report!

planeth44 commented 6 years ago

I came up with a temporary fix in the list template

            {% if crudData.getDefinition().getType(filterField) == 'reference' and filterValue.id is defined %}
                {% set filterValue = filterValue.id %}
            {% endif %}
philiplb commented 6 years ago

This has been fixed via https://github.com/philiplb/CRUDlex/commit/8a1a6eb3e2134c93554edba2765531c495835970 . Looking forward to the release of 0.14.0 tomorrow or monday. :)

planeth44 commented 6 years ago

Splendid!