Beispiel #1
0
 /**
  * @param BuildableInterface $container
  * @param FormState $context
  * @param array $errors
  */
 public function buildErrors(BuildableInterface $container, FormState $context, array $errors)
 {
     foreach ($errors as $index => $e) {
         if ($e instanceof ComponentException) {
             $container->addLabel('lblError' . $index, $e->getComponent()->getId())->setFor($e->getComponent())->addCssClass(CssClass::ERROR)->setTranslationKey('error.' . $e->getType(), $e->getParams());
         } elseif ($e instanceof FormException) {
             $container->addLabel('lblError' . $index)->addCssClass(CssClass::ERROR)->setTranslationKey('error.' . $e->getType(), $e->getParams());
         } elseif ($e instanceof \Exception) {
             $container->addLabel('lblError' . $index)->addCssClass(CssClass::ERROR)->setContent($e->getMessage() . get_class($e));
             //->setTranslationKey('error.generic')
             // TODO: check debug mode: if debug, show full exception text, else show generic error
         }
     }
 }
Beispiel #2
0
 /**
  * @param BuildableInterface $container
  * @param $key
  * @param $value
  * @param FormState $state
  */
 protected function addOption(BuildableInterface $container, $key, $value, FormState $state)
 {
     $label = $container->addLabel('lbl' . ucfirst($key));
     $checkbox = $container->addCheckbox($key);
     $label->setFor($checkbox);
 }