Skip to content

Commit

Permalink
Merge pull request bolt#16 from oportier/patch-1
Browse files Browse the repository at this point in the history
Fix labels customization when $labels is passed to "login_form()"
  • Loading branch information
I-Valchev authored Mar 4, 2021
2 parents 6a49db9 + 14a65a3 commit 2bc00bf
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Twig/LoginFormExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function getLoginForm(bool $withLabels = true, array $labels = []): strin

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 @@ -74,7 +74,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 @@ -84,7 +84,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 @@ -94,7 +94,7 @@ public function getEmailField(bool $withLabel, array $labels): 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 2bc00bf

Please sign in to comment.