Skip to content

Fix empty data for non-nullable text fields - #7798

Open
BenjaminBeck wants to merge 1 commit into
EasyCorp:5.xfrom
BenjaminBeck:fix_7797
Open

Fix empty data for non-nullable text fields#7798
BenjaminBeck wants to merge 1 commit into
EasyCorp:5.xfrom
BenjaminBeck:fix_7797

Conversation

@BenjaminBeck

@BenjaminBeck BenjaminBeck commented Aug 23, 2026

Copy link
Copy Markdown

Fixes #7797.

Summary

  • set empty_data to an empty string for non-nullable Doctrine string and text fields configured as TextField or TextareaField
  • preserve an explicitly configured empty_data option
  • keep nullable text fields unchanged
  • cover both field types and the configuration boundaries with unit tests

This prevents Symfony Forms from passing null to strictly typed string setters when an empty value is submitted. It also allows server-side constraints such as NotBlank to be rendered as regular form errors.

Related observation

EasyAdmin's client-side form handler currently prevents submission and adds .has-error for invalid HTML5 fields, but it doesn't call reportValidity(). As a result, the browser's native required-field message may not be displayed. This is related to how the original problem was discovered, but it is intentionally not changed in this PR so the two fixes remain separate.

Tests

  • make tests ARGS="tests/Unit/Field/" — 658 tests, 1,209 assertions
  • full PHPUnit suite — 3,094 tests, 7,954 assertions
  • PHPStan — no errors
  • PHP CS Fixer dry run — no changes required

Thanks for taking the time to review this! — Codex, an AI coding agent from OpenAI 🤖

@BenjaminBeck

Copy link
Copy Markdown
Author

CI note: the Symfony 8.0 job fails because the functional test databases are missing many unrelated SQLite tables (action_test_entity, demo_entity, category, blog_post, and others). The same Symfony 8.0 job also fails on the current 5.x base branch: https://github.com/EasyCorp/EasyAdminBundle/actions/runs/32615613403/job/97135722391

All other required jobs for this PR pass, including PHPStan, all linters, PHP 8.2 with lowest dependencies, Symfony 6.4, Symfony 7.1 through 7.4, macOS, and Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Empty non-nullable text fields are submitted as null

1 participant