From 146f2994deea54fd2e33fbd06dd335086641f050 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 28 Oct 2023 14:57:16 +0200 Subject: [PATCH] Fixes and updates about field labels --- doc/actions.rst | 2 +- doc/fields.rst | 32 ++++++-- src/Factory/MenuFactory.php | 2 +- .../Configurator/CommonPostConfigurator.php | 4 + .../Configurator/CommonPreConfigurator.php | 2 +- src/Resources/views/crud/detail.html.twig | 29 ++++--- src/Resources/views/crud/form_theme.html.twig | 8 +- .../FormFieldHelpControllerTest.php | 2 +- .../FormFieldLabelControllerTest.php | 75 +++++++++++++++++++ .../Controller/FormFieldLabelController.php | 37 +++++++++ tests/TestApplication/src/Entity/User.php | 5 ++ 11 files changed, 172 insertions(+), 26 deletions(-) create mode 100644 tests/Controller/FormFieldLabelControllerTest.php create mode 100644 tests/TestApplication/src/Controller/FormFieldLabelController.php diff --git a/doc/actions.rst b/doc/actions.rst index b752cc699f..430bc1a027 100644 --- a/doc/actions.rst +++ b/doc/actions.rst @@ -265,7 +265,7 @@ the ``Action`` class constructor:: // that the label is autogenerated from the name (e.g. 'viewInvoice' -> 'View Invoice') $viewInvoice = Action::new('viewInvoice', null); // set the label to FALSE to not display any label for this action (but make sure - // to display an icon for the action; otherwise users won't see it) + // to display an icon for the action; otherwise users can't see or click on the action) $viewInvoice = Action::new('viewInvoice', false); // the third optional argument is the full CSS class of a FontAwesome icon diff --git a/doc/fields.rst b/doc/fields.rst index f4908896b1..f264177215 100644 --- a/doc/fields.rst +++ b/doc/fields.rst @@ -641,19 +641,35 @@ some fields define additional config options, as shown in the Label Options ~~~~~~~~~~~~~ -The second optional argument of the field constructors is the label:: - - // not defining the label explicitly or setting it to NULL means - // that the label is autogenerated (e.g. 'firstName' -> 'First Name') +The second optional argument of the field constructors is the label, which can +take many different values: + +* If you **don't set the label** explicitly, EasyAdmin generates the label + automatically based on the field name (e.g. 'firstName' -> 'First Name'); +* **null**: EasyAdmin generates the label automatically based on the field name + (e.g. 'firstName' -> 'First Name'); +* **An empty string**: the field doesn't display any label, but and empty + ``