Enum editing

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1240 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
jakubvrana 2009-11-12 15:25:21 +00:00
parent e70157827f
commit ec0282b7d7
3 changed files with 11 additions and 6 deletions

View file

@ -404,7 +404,12 @@ class Adminer {
* @return string custom input field or empty string for default
*/
function editInput($table, $field, $attrs, $value) {
return '';
if ($field["type"] == "enum") {
return ($field["null"] ? "<label><input type='radio'$attrs value=''" . (isset($value) || isset($_GET["select"]) ? "" : " checked") . "><em>NULL</em></label> " : "")
. "<input type='radio'$attrs value='0'" . ($value === 0 ? " checked" : "") . ">"
;
}
return "";
}
/** Process sent input

View file

@ -417,11 +417,8 @@ function input($field, $value, $function) {
echo "<td class='function'>";
$functions = (isset($_GET["select"]) ? array("orig" => lang('original')) : array()) + $adminer->editFunctions($field);
if ($field["type"] == "enum") {
echo "&nbsp;<td>" . ($functions["orig"] ? "<label><input type='radio' name='fields[$name]' value='-1' checked><em>$functions[orig]</em></label> " : "");
if (in_array("NULL", $functions)) {
echo "<label><input type='radio' name='fields[$name]' value=''" . (isset($value) || $functions["orig"] ? '' : ' checked') . "><em>NULL</em></label> ";
}
echo "<input type='radio' name='fields[$name]' value='0'" . ($value === 0 ? ' checked' : '') . '>';
echo nbsp($functions[""]) . "<td>" . ($functions["orig"] ? "<label><input type='radio' name='fields[$name]' value='-1' checked><em>$functions[orig]</em></label> " : "");
echo $adminer->editInput($_GET["edit"], $field, " name='fields[$name]'", $value);
preg_match_all("~'((?:[^']|'')*)'~", $field["length"], $matches);
foreach ($matches[1] as $i => $val) {
$val = stripcslashes(str_replace("''", "'", $val));

View file

@ -394,6 +394,9 @@ ORDER BY ORDINAL_POSITION");
function editInput($table, $field, $attrs, $value) {
global $connection;
if ($field["type"] == "enum") {
return ($field["null"] ? "<input type='radio'$attrs value=''" . ($value || isset($_GET["select"]) ? "" : " checked") . ">" : "");
}
$foreignKeys = column_foreign_keys($table);
foreach ((array) $foreignKeys[$field["field"]] as $foreignKey) {
if (count($foreignKey["source"]) == 1) {