/**
  * @param ElementInterface $element
  * @param ModelBuilder $mb
  */
 public function buildFormElement(ElementInterface $element, ModelBuilder $mb)
 {
     // Only continue if the element has to be mapped to a model.
     if ($element instanceof MultipleChoice && !$element->isMapped()) {
         return;
     }
     $name = $element->getName();
     switch ($element) {
         case $element instanceof Element\Text:
             $mb->column($name)->type('string');
             break;
         case $element instanceof Element\Textarea:
             $mb->column($name)->type('text');
             break;
         case $element->hasRule('integer'):
             $mb->column($name)->type('integer');
             break;
         case $element instanceof Element\ModelElement && $element instanceof Type\Choice:
             $mb->column($name)->type('integer');
             break;
         default:
             $mb->column($name)->type('string');
     }
     if ($element->getRules()) {
         $mb->get($name)->validate($element->getRules());
     }
 }
 /**
  * @param Column  $column
  * @param ElementInterface $element
  */
 public function onBuildColumn(Column $column, ElementInterface $element, $record)
 {
     if (!$element instanceof ImageElement) {
         return;
     }
     $name = $element->getName();
     if (!isset($record->{$name})) {
         return;
     }
     $path = $record->{$name};
     $route = sprintf('image/%d/%d/%s', $this->width, $this->height, $path);
     $value = HTML::image($route);
     $column->setValue($value);
 }