/** * Modify the label. * * @param ContextualConfig|Config $config The bootstrap config. * @param Label $label The label class. * @param \Widget $widget The widget. * * @return void */ private function modifyLabel($config, Label $label, \Widget $widget) { if (!$widget->label || !$this->getWidgetConfigValue($config, $widget->type, 'label', true)) { $label->hide(); } else { $label->addClass('control-label'); } }
/** * 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); }