/** * Convert all the table columns into form elements * * @return array * @throws \Exception */ public function getElements() { if (!$this->table instanceof Table) { throw new \Exception('Table not set'); } $pkColumns = $this->table->getPrimaryKey()->getColumns(); $elements = []; $fks = []; $fk = $this->table->getForeignKeys(); if (!empty($fk)) { foreach ($fk as $f) { $fks = array_merge($fks, $f->getLocalColumns()); } } foreach ($this->table->getColumns() as $column) { $isPrimaryKey = in_array($column->getName(), $pkColumns); if ($this->helper->isExcluded($column) || $isPrimaryKey) { continue; } $elements[] = $this->mapColumn($column, $fks); } return $elements; }