/** * Get the value of this Record's title column. * @return string */ public function getTitle() { $title_col = $this->table->getTitleColumn(); if ($title_col !== $this->table->getPkColumn()) { $title_col_name = $title_col->getName(); return $this->data->{$title_col_name}; } else { $title_parts = array(); foreach ($this->table->getColumns() as $col) { $col_name = $col->getName() . self::FKTITLE; $title_parts[] = $this->{$col_name}(); } return '[ ' . join(' | ', $title_parts) . ' ]'; } }
/** * Get a set of results for Foreign Key lookups. * @param \Tabulate\DB\Table $table The table to search. * @param string $operator One of the permitted filter operators. * @param string $term The search term. * @return string[] */ protected function foreign_key_values_build($table, $operator, $term) { $table->resetFilters(); $table->addFilter($table->getTitleColumn(), $operator, $term); $out = array(); foreach ($table->getRecords() as $record) { $out[$record->getPrimaryKey()] = array('value' => $record->getPrimaryKey(), 'label' => $record->getTitle()); } return $out; }