Skip to content

Commit

Permalink
Fix labels customization when $labels is passed to registration_form()
Browse files Browse the repository at this point in the history
As for PR #16 this commit fix labels for call to twig function `registration_form('ROLE_USER', true, $labels)`
  • Loading branch information
oportier authored Mar 4, 2021
1 parent 2bc00bf commit cab5e5f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Twig/RegistrationFormExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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('<label for="displayname">%s</label>', $text) : '';

$input = '<input type="text" id="displayname" name="displayname">';
Expand All @@ -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('<label for="username">%s</label>', $text) : '';

$input = '<input type="text" id="username" name="username">';
Expand All @@ -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('<label for="password">%s</label>', $text) : '';

$input = '<input type="password" id="password" name="password">';
Expand All @@ -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('<label for="email">%s</label>', $text) : '';

$input = '<input type="email" id="email" name="email">';
Expand All @@ -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('<input type="submit" value="%s">', $text);
}
Expand Down

0 comments on commit cab5e5f

Please sign in to comment.