/**
  * Generate the password confirmation field.
  *
  * @param ViewEvent $event Event listened to.
  *
  * @return void
  */
 public function generatePasswordConfirmation(ViewEvent $event)
 {
     $view = $event->getView();
     $widget = $view->getWidget();
     if (!$widget instanceof \FormPassword) {
         return;
     }
     $container = $view->getContainer();
     $element = $container->getElement();
     $label = $view->getLabel();
     $widgetId = $element instanceof Element ? $element->getId() : 'ctrl_' . $widget->id;
     $repeatId = $widgetId . '_confirm';
     $repeatLabel = new Label();
     $repeatLabel->setAttribute('class', $label->getAttribute('class'))->addChild($this->createConfirmationLabel($widget))->setAttribute('for', $repeatId);
     if ($widget->mandatory) {
         $mandatory = $this->createMandatoryLabel();
         $repeatLabel->addChild($mandatory);
     }
     /** @var Element $repeat */
     $repeat = clone $element;
     $repeat->setId($repeatId)->setAttribute('name', $repeat->getAttribute('name') . '_confirm')->setAttribute('value', '');
     $container->addChild('repeat', $repeat);
     $container->addChild('repeatLabel', $repeatLabel);
 }