\n";
+# Start of form
+print &ui_form_start("save_field.cgi");
+print &ui_hidden("db", $in{'db'});
+print &ui_hidden("table", $in{'table'});
+print &ui_hidden("new", $in{'type'});
+print &ui_table_start($text{'field_header'}, undef, 2);
-print " $text{'field_name'} \n";
-print " \n";
-print " \n" if (!$in{'type'});
+# Field name
+print &ui_table_row($text{'field_name'},
+ &ui_textbox("field", $f->{'field'}, 20));
+print &ui_hidden("old", $f->{'field'}) if (!$in{'type'});
+# Type
if ($type =~ /^(\S+)\((.*)\)(.*)/) {
$type = $1;
$size = $2;
$extra = $3;
}
-print " \n";
-print " $text{'field_type'} \n";
+print &ui_hidden("type", $type);
if ($in{'type'}) {
# New field .. just show chosen type
- print "$type \n";
+ $tsel = $type;
}
else {
# Existing field .. allow type change
- print "\n";
- foreach $t (@type_list) {
- printf "%s\n",
- $t eq $type ? "selected" : "", $t;
- }
- print " $text{'field_typewarn'} \n";
+ $tsel = &ui_select("newtype", $type, \@type_list)." ".
+ $text{'field_typewarn'};
}
+print &ui_table_row($text{'field_type'}, $tsel);
if ($type eq 'enum' || $type eq 'set') {
# List of values
local @ev = &split_enum($size);
- print " $text{'field_enum'} \n";
- print " \n";
+ print &ui_table_row($text{'field_enum'},
+ &ui_textarea("size", join("\n", @ev), 4, 20));
}
elsif ($type eq 'float' || $type eq 'double' || $type eq 'decimal') {
- # Two values
- print " $text{'field_dual'} \n";
- printf " \n",
- $size =~ /^(\d+)/ ? $1 : '';
- printf " \n",
- $size =~ /(\d+)$/ ? $1 : '';
+ # Two values, for total and decimal
+ print &ui_table_row($text{'field_dual'},
+ &ui_textbox("size1", $size =~ /^(\d+)/ ? $1 : '', 5)."\n".
+ &ui_textbox("size2", $size =~ /(\d+)$/ ? $1 : '', 5));
}
elsif ($type eq 'date' || $type eq 'datetime' || $type eq 'time' ||
$type eq 'timestamp' || $type =~ /(blob|text)$/) {
@@ -74,90 +68,69 @@ elsif ($type eq 'date' || $type eq 'datetime' || $type eq 'time' ||
}
elsif ($type ne 'varchar' && $type ne 'char' && $in{'type'}) {
# Size is optional for new fields of most types
- print " $text{'field_size'} \n";
- print " ",
- "$text{'default'}\n";
- print " \n";
- print " \n";
+ print &ui_table_row($text{'field_size'},
+ &ui_opt_textbox("size", undef, $text{'default'}, 10));
}
else {
- # One single value
- print " $text{'field_size'} \n";
- print " \n";
+ # Size is one value
+ print &ui_table_row($text{'field_size'},
+ &ui_textbox("size", $size, 10));
}
if ($type =~ /int$/) {
# Display unsigned/zerofill option
- print " $text{'field_opts'} \n";
- printf " %s\n",
- $extra =~ /unsigned/ ? '' : 'checked',
- $text{'field_none'};
- printf " %s\n",
- $extra =~ /unsigned/ && $extra !~ /zerofill/ ? 'checked' : '',
- $text{'field_unsigned'};
- printf " %s \n",
- $extra =~ /zerofill/ ? 'checked' : '',
- $text{'field_zerofill'};
+ print &ui_table_row($text{'field_opts'},
+ &ui_radio("opts", $extra =~ /unsigned/ ? 'unsigned' :
+ $extra =~ /zerofill/ ? 'zerofill' : '',
+ [ [ '', $text{'field_none'} ],
+ [ 'unsigned', $text{'field_unsigned'} ],
+ [ 'zerofill', $text{'field_zerofill'} ] ]));
# Display auto-increment option
- print " $text{'field_auto'} \n";
- printf " %s\n",
- 'auto_increment',
- $f->{'extra'} =~ /auto_increment/ ? 'checked' : '',
- $text{'yes'};
- printf " %s \n",
- $f->{'extra'} =~ /auto_increment/ ? '' : 'checked',
- $text{'no'};
+ print &ui_table_row($text{'field_auto'},
+ &ui_radio("ext", $f->{'extra'} =~ /auto_increment/ ?
+ 'auto_increment' : '',
+ [ [ 'auto_increment', $text{'yes'} ],
+ [ '', $text{'no'} ] ]));
}
elsif ($type eq 'float' || $type eq 'double' || $type eq 'decimal') {
# Display zerofill option
- print " $text{'field_opts'} \n";
- printf " %s\n",
- $extra =~ /unsigned/ ? '' : 'checked',
- $text{'field_none'};
- printf " %s \n",
- $extra =~ /zerofill/ ? 'checked' : '',
- $text{'field_zerofill'};
+ print &ui_table_row($text{'field_opts'},
+ &ui_radio("opts", $extra =~ /zerofill/ ? 'zerofill' : '',
+ [ [ '', $text{'field_none'} ],
+ [ 'zerofill', $text{'field_zerofill'} ] ]));
}
elsif ($type eq 'char' || $type eq 'varchar') {
# Display binary option
- print " $text{'field_opts'} \n";
- printf " %s\n",
- $extra =~ /binary/ ? '' : 'checked',
- $text{'field_ascii'};
- printf " %s \n",
- $extra =~ /binary/ ? 'checked' : '',
- $text{'field_binary'};
+ print &ui_table_row($text{'field_opts'},
+ &ui_radio("opts", $extra =~ /binary/ ? 'binary' : '',
+ [ [ '', $text{'field_ascii'} ],
+ [ 'binary', $text{'field_binary'} ] ]));
}
-print " $text{'field_null'} \n";
-printf " $text{'yes'}\n",
- $in{'type'} || $f->{'null'} eq 'YES' ? 'checked' : '';
-printf " $text{'no'} \n",
- $in{'type'} || $f->{'null'} eq 'YES' ? '' : 'checked';
+# Allow nulls?
+print &ui_table_row($text{'field_null'},
+ &ui_radio("null", $in{'type'} || $f->{'null'} eq 'YES' ? 1 : 0,
+ [ [ 1, $text{'yes'} ], [ 0, $text{'no'} ] ]));
-print " $text{'field_default'} \n";
-printf " \n",
- $f->{'default'} eq 'NULL' ? '' : $f->{'default'};
+# Default value
+print &ui_table_row($text{'field_default'},
+ &ui_textbox("default", $f->{'default'} eq 'NULL' ? '' :
+ $f->{'default'}, 40));
-print " $text{'field_key'} \n";
-printf " %s\n",
- $f->{'key'} eq 'PRI' ? 'checked' : '', $text{'yes'};
-printf " %s \n",
- $f->{'key'} eq 'PRI' ? '' : 'checked', $text{'no'};
-printf " \n",
- $f->{'key'} eq 'PRI' ? 1 : 0;
+# Part of primary key
+print &ui_table_row($text{'field_key'},
+ &ui_yesno_radio("key", $f->{'key'} eq 'PRI' ? 1 : 0));
+print &ui_hidden("oldkey", $f->{'key'} eq 'PRI' ? 1 : 0);
-print "