Limiter le nombre de caractères des champs de saisie dans le formulaire de création/modification d’un budget
Dans le formulaire d’édition d’un budget, la saisie d’un titre ou d’une description de plus de 255 caractères génère une erreur (500 Internal Error) lors de l’enregistrement.
Exemple de retour d’erreur dans le journal prod.log
:
[2024-02-21T16:54:49.602762+01:00] request.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\DriverException: "An exception occurred while executing 'INSERT INTO budget (slug, title, subtitle, rules, tags, amount, unit, timetracking, created, unit_symbol, archived, referent_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params ["56b99bd8-992f-42c1-a118-31ccf312f150", "…", null, null, null, null, 0, "2024-02-21 16:54:49", null, 0, 1]: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'title' at row 1" at …/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 128 {"exception":"[object] (Doctrine\\DBAL\\Exception\\DriverException(code: 0): An exception occurred while executing 'INSERT INTO budget (slug, title, subtitle, rules, tags, amount, unit, timetracking, created, unit_symbol, archived, referent_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params [\"56b99bd8-992f-42c1-a118-31ccf312f150\", \"…\", null, null, null, null, 0, \"2024-02-21 16:54:49\", null, 0, 1]:\n\nSQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'title' at row 1 at …/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:128)\n[previous exception] [object] (Doctrine\\DBAL\\Driver\\PDO\\Exception(code: 22001): SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'title' at row 1 at …/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDO/Exception.php:18)\n[previous exception] [object] (PDOException(code: 22001): SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'title' at row 1 at …/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:117)"} []
[2024-02-21T16:54:49.604777+01:00] security.DEBUG: Stored the security token in the session. {"key":"_security_main"} []
Limiter les champs de saisie à 255 caractères avec l’attribut HTML maxlength
devrait résoudre le problème. Il est probable que ce problème se retrouve sur d’autres champs de saisie que le seul formulaire d’édition d’un budget.
Edited by Benjamin Danon