Exemple #1
0
 /**
  * Takes information from the Field and uses it in this display
  * 
  * @param DisplayDataSourceInterface $field
  */
 public function informAboutStructure(\Feeld\Display\DisplayDataSourceInterface $field)
 {
     parent::informAboutStructure($field);
     if (!$field instanceof \Feeld\Interview\ErrorContainer) {
         throw new \Wellid\Exception\DataType('field', 'ErrorContainer', $field);
     }
     $errorMessages = $errorMessagesLi = array();
     foreach ($field->getErrorMessages() as $entry) {
         $errorMessages[] = htmlspecialchars($entry);
         $errorMessagesLi[] = '<li>' . htmlspecialchars($entry) . '</li>';
     }
     if (count($errorMessages) === 0) {
         $this->setInvisible();
         return;
     }
     $this->setVisible();
     if (count($errorMessages) === 1) {
         $innerWrapper = (new Element('span'))->setContent($errorMessages[0]);
     } else {
         $innerWrapper = (new Element('ul'))->setContent(implode('', $errorMessagesLi));
     }
     $this->appendChild($innerWrapper->addCssClass('bg-danger error'));
 }