From cab5e5ffa8ece0f7426c3d87e93171a64427ae2a Mon Sep 17 00:00:00 2001 From: Olivier PORTIER Date: Thu, 4 Mar 2021 17:28:06 +0100 Subject: [PATCH] Fix labels customization when $labels is passed to registration_form() As for PR https://github.com/bolt/users/pull/16 this commit fix labels for call to twig function `registration_form('ROLE_USER', true, $labels)` --- src/Twig/RegistrationFormExtension.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Twig/RegistrationFormExtension.php b/src/Twig/RegistrationFormExtension.php index a76f4f6..e403f5e 100644 --- a/src/Twig/RegistrationFormExtension.php +++ b/src/Twig/RegistrationFormExtension.php @@ -60,7 +60,7 @@ public function getRegistrationForm(string $group, bool $withLabels = true, arra public function getDisplayNameField(bool $withLabel, array $labels): string { - $text = in_array('displayname', $labels, true) ? $labels['displayname'] : 'Display Name'; + $text = array_key_exists('displayname', $labels) ? $labels['displayname'] : 'Display Name'; $label = $withLabel ? sprintf('', $text) : ''; $input = ''; @@ -70,7 +70,7 @@ public function getDisplayNameField(bool $withLabel, array $labels): string public function getUsernameField(bool $withLabel, array $labels): string { - $text = in_array('username', $labels, true) ? $labels['username'] : 'Username'; + $text = array_key_exists('username', $labels) ? $labels['username'] : 'Username'; $label = $withLabel ? sprintf('', $text) : ''; $input = ''; @@ -80,7 +80,7 @@ public function getUsernameField(bool $withLabel, array $labels): string public function getPasswordField(bool $withLabel, array $labels): string { - $text = in_array('password', $labels, true) ? $labels['password'] : 'Password'; + $text = array_key_exists('password', $labels) ? $labels['password'] : 'Password'; $label = $withLabel ? sprintf('', $text) : ''; $input = ''; @@ -90,7 +90,7 @@ public function getPasswordField(bool $withLabel, array $labels): string public function getEmailField(bool $withLabel, array $labels): string { - $text = in_array('email', $labels, true) ? $labels['email'] : 'Email'; + $text = array_key_exists('email', $labels) ? $labels['email'] : 'Email'; $label = $withLabel ? sprintf('', $text) : ''; $input = ''; @@ -105,7 +105,7 @@ public function getGroupField(string $group): string public function getSubmitButton(array $labels = []): string { - $text = in_array('submit', $labels, true) ? $labels['submit'] : 'Submit'; + $text = array_key_exists('submit', $labels) ? $labels['submit'] : 'Submit'; return sprintf('', $text); }