Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 31 lines (27 sloc) 1.003 kb
08e70e6 @vrana Edit foreign plugin
authored
1 <?php
2
3 /** Select foreign key in edit form
4 * @author Jakub Vrana, http://www.vrana.cz/
5 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
6 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
7 */
8 class AdminerEditForeign {
9
10 function editInput($table, $field, $attrs, $value) {
11 static $foreignTables = array();
12 static $values = array();
13 $foreignKeys = &$foreignTables[$table];
6591d48 @vrana Replace isset($var) by $var !== null
authored
14 if ($foreignKeys === null) {
08e70e6 @vrana Edit foreign plugin
authored
15 $foreignKeys = column_foreign_keys($table);
16 }
17 foreach ((array) $foreignKeys[$field["field"]] as $foreignKey) {
18 if (count($foreignKey["source"]) == 1) {
19 $target = $foreignKey["table"];
20 $id = $foreignKey["target"][0];
21 $options = &$values[$target][$id];
22 if (!$options) {
23 $options = array("" => "") + get_vals("SELECT " . idf_escape($id) . " FROM " . table($target) . " ORDER BY 1");
24 }
25 return "<select$attrs>" . optionlist($options, $value) . "</select>";
26 }
27 }
28 }
29
30 }
Something went wrong with that request. Please try again.