- Basic form field
- Policy modes
- Validator constraint
- Generator
- Feedback position
- HTML pattern
- Overriding bundle templates (REQ-TWIG-001)
- Translation overrides (REQ-I18N-001)
- Demo routes
- Related bundles
use Nowo\PasswordStrengthBundle\Form\PasswordStrengthType;
$builder->add('password', PasswordStrengthType::class, [
'policy_mode' => 'level',
'level' => 'medium',
]);The field value is a password string. The widget is the <nowo-password-strength> custom element (light DOM: native input + requirements list). Include password-strength.js after assets:install.
$builder->add('password', PasswordStrengthType::class, [
'policy_mode' => 'level',
'level' => 'strong', // weak | medium | strong | custom
]);$builder->add('password', PasswordStrengthType::class, [
'policy_mode' => 'conditions',
'conditions' => [
'min_length' => 10,
'require_lowercase' => true,
'require_uppercase' => true,
'require_digit' => true,
'require_special' => true,
'not_contain' => ['password', '123456'],
],
]);Use on entity or DTO for server-side validation (recommended alongside the form type):
use Nowo\PasswordStrengthBundle\Validator\PasswordStrength;
#[PasswordStrength(
policyMode: 'level',
level: 'medium',
)]
private ?string $password = null;Or with inline conditions:
#[PasswordStrength(
policyMode: 'conditions',
conditions: ['min_length' => 8, 'require_digit' => true],
)]
private ?string $password = null;$builder->add('password', PasswordStrengthType::class, [
'generator_mode' => 'modal', // off | input | modal
'generator_count' => 5,
]);$builder->add('password', PasswordStrengthType::class, [
'feedback_position' => 'above',
]);The widget sets pattern on the input from the active policy. Browsers may use it for native validation; always rely on the PasswordStrength validator for authoritative checks.
Application overrides always win when placed under:
templates/bundles/NowoPasswordStrengthBundle/<subpath>
Procedure
- Pick the
<subpath>from the table below (same path as undersrc/Resources/views/in the package). - Create
templates/bundles/NowoPasswordStrengthBundle/<subpath>in your app. - Clear cache in dev if needed:
php bin/console cache:clear.
| Subpath | Purpose |
|---|---|
Form/password_strength_theme.html.twig |
Base div layout theme |
Form/password_strength_theme_table.html.twig |
Table layout theme |
Form/password_strength_theme_bootstrap3.html.twig |
Bootstrap 3 |
Form/password_strength_theme_bootstrap3_horizontal.html.twig |
Bootstrap 3 horizontal |
Form/password_strength_theme_bootstrap4.html.twig |
Bootstrap 4 |
Form/password_strength_theme_bootstrap4_horizontal.html.twig |
Bootstrap 4 horizontal |
Form/password_strength_theme_bootstrap5.html.twig |
Bootstrap 5 |
Form/password_strength_theme_bootstrap5_horizontal.html.twig |
Bootstrap 5 horizontal |
Form/password_strength_theme_tailwind2.html.twig |
Tailwind 2 |
Form/password_strength_theme_foundation5.html.twig |
Foundation 5 |
Form/password_strength_theme_foundation6.html.twig |
Foundation 6 |
Twig namespace: @NowoPasswordStrengthBundle/Form/... (registered via TwigPathsPass).
Domain: NowoPasswordStrengthBundle (same as translation_domain on the form type).
Procedure
- Create
translations/NowoPasswordStrengthBundle.<locale>.yamlin your application. - Override only the keys you need; missing keys fall back to the bundle.
Example translations/NowoPasswordStrengthBundle.es.yaml:
requirement:
min_length: 'Al menos %count% caracteres'
lowercase: 'Al menos una letra minúscula'
generator:
button: 'Generar contraseña'See bundle defaults in src/Resources/translations/NowoPasswordStrengthBundle.en.yaml.
See DEMO-FRANKENPHP.md. Examples:
/en/demo/level— level presets/en/demo/conditions— inline conditions/en/demo/plain— SymfonyPasswordTypecomparison
- PasswordToggleBundle — optional show/hide toggle