esWidgetFormPasswordPlugin - 0.1.3

Emmanuel Szep

You are currently browsing
the website for symfony 1

Visit the Symfony2 website

« Back to the Plugins Home


Forgot your password?
Create an account



advanced search
Information Readme Releases Changelog Contribute
Show source

Password widget and validator

  • The widget displays a password and password confirmation fields with an optional bit of javascript to replace the confirmation field by a reveal password toggle.
  • The validator validates both password and confirmation with an option to generate a random password (configurable password complexity), min_length, max_length.


  • Install the plugin (via a package)

    symfony plugin:install esWidgetFormPasswordPlugin
  • Activate the plugin in the config/ProjectConfiguration.class.php


    class ProjectConfiguration extends sfProjectConfiguration
      public function setup()
  • Clear you cache

    symfony cc


In your form class

  • add a widget for the password field


    'password' => new esWidgetFormPassword(array())
  • Add a post validator


    $this->validatorSchema->setOption('allow_extra_fields', true);
    $this->validatorSchema->setOption('filter_extra_fields', false);
    $this->validatorSchema->setPostValidator(new esValidatorSchemaPassword('password', array('min_length' => 8)));


  • Widget


    'password' => new esWidgetFormPassword(array(
      'confirm_label' => 'Confirm password', // Label for the password confirmation field
      'show_password_label' => 'Reveal password', // label of the reveal password checkbox
      'enable_reveal_toggle' => true, // Enable or disable the toggle (Javascript)
      'template' => '%input%<br />%confirm_label%<br />%confirm%'
  • Validator


    $this->validatorSchema->setPostValidator(new esValidatorSchemaPassword('password', array(
        'generate_for_empty' => true, // Generate a random password if field is empty
        'required' => true, // If no password is generated should the validator allow an empty one ?
        'min_length' => 8,
        'max_length' => 50