Example #1
0
 /**
  * Maps an individual column in to a Form element
  *
  * @param Column $column
  * @return ElementInterface
  */
 protected function mapColumn(Column $column, $fks)
 {
     $attributes = ['name' => $column->getName(), 'id' => str_replace('_', '-', $column->getName()), 'class' => null];
     if ($this->helper->isEmail($column)) {
         $element = new Email($attributes);
     } elseif ($this->helper->isPassword($column)) {
         $element = new Password($attributes);
     } elseif ($this->helper->isHidden($column)) {
         $element = new Hidden($attributes);
     } elseif ($this->helper->isBoolean($column)) {
         $element = new Boolean($attributes);
     } elseif ($this->helper->isDate($column)) {
         $element = new Date($attributes);
     } elseif ($this->helper->isSelect($column, $fks)) {
         $element = new Select($attributes);
     } elseif ($this->helper->isTextArea($column)) {
         $element = new TextArea($attributes);
     } elseif ($this->helper->isString($column)) {
         $attributes['maxlength'] = $column->getLength();
         $element = new Text($attributes);
     } elseif ($this->helper->isNumeric($column)) {
         $element = new Numeric($attributes);
     } else {
         $element = new Text($attributes);
     }
     $element->setRequired($column->getNotnull());
     return $element;
 }