]> git.joonet.de Git - adminer.git/commitdiff
Mark length as required for strings
authorJakub Vrana <jakub@vrana.cz>
Sun, 7 Jul 2013 06:05:27 +0000 (23:05 -0700)
committerJakub Vrana <jakub@vrana.cz>
Sun, 7 Jul 2013 06:06:50 +0000 (23:06 -0700)
Uses <input formnovalidate> instead of <form novalidate> to highlight error fields.

adminer/create.inc.php
adminer/include/editing.inc.php
adminer/static/editing.js
changes.txt

index 1bb8715d172985b9927771be98e6bd80172c2314..0c85ac44185b835a6ca117a403571c61416aa613 100644 (file)
@@ -158,7 +158,7 @@ foreach ($engines as $engine) {
 <?php if ($TABLE == "" && !$_POST) { ?><script type='text/javascript'>focus(document.getElementById('form')['name']);</script><?php } ?>
 <?php echo ($engines ? html_select("Engine", array("" => "(" . lang('engine') . ")") + $engines, $row["Engine"]) : ""); ?>
  <?php echo ($collations && !ereg("sqlite|mssql", $jush) ? html_select("Collation", array("" => "(" . lang('collation') . ")") + $collations, $row["Collation"]) : ""); ?>
- <input type="submit" value="<?php echo lang('Save'); ?>">
+ <input type="submit" value="<?php echo lang('Save'); ?>" formnovalidate>
 <table cellspacing="0" id="edit-fields" class="nowrap">
 <?php
 $comments = ($_POST ? $_POST["comments"] : $row["Comment"] != "");
@@ -183,8 +183,8 @@ edit_fields($row["fields"], $collations, "TABLE", $foreign_keys, $comments);
        : '')
 ; ?>
 <p>
-<input type="submit" value="<?php echo lang('Save'); ?>">
-<?php if ($TABLE != "") { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo confirm(); ?>><?php } ?>
+<input type="submit" value="<?php echo lang('Save'); ?>" formnovalidate>
+<?php if ($TABLE != "") { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo confirm(); ?> formnovalidate><?php } ?>
 <?php
 if (support("partitioning")) {
        $partition_table = ereg('RANGE|LIST', $row["partition_by"]);
index 02107f6de18517826d5a8b746fda5008cbbdaf13..814e6778af6742de41673ab3ff5a0ccf28bdc50e 100644 (file)
@@ -140,7 +140,7 @@ function edit_type($key, $field, $collations, $foreign_keys = array()) {
        global $structured_types, $types, $unsigned, $on_actions;
        ?>
 <td><select name="<?php echo $key; ?>[type]" class="type" onfocus="lastType = selectValue(this);" onchange="editingTypeChange(this);"><?php echo optionlist((!$field["type"] || isset($types[$field["type"]]) ? array() : array($field["type"])) + $structured_types + ($foreign_keys ? array(lang('Foreign keys') => $foreign_keys) : array()), $field["type"]); ?></select>
-<td><input name="<?php echo $key; ?>[length]" value="<?php echo h($field["length"]); ?>" size="3" onfocus="editingLengthFocus(this);"><td class="options"><?php //! type="number" with enabled JavaScript
+<td><input name="<?php echo $key; ?>[length]" value="<?php echo h($field["length"]); ?>" size="3" onfocus="editingLengthFocus(this);"<?php echo (ereg('var(char|binary)$', $field["type"]) ? " required" : ""); ?>><td class="options"><?php //! type="number" with enabled JavaScript
        echo "<select name='$key" . "[collation]'" . (ereg('(char|text|enum|set)$', $field["type"]) ? "" : " class='hidden'") . '><option value="">(' . lang('collation') . ')' . optionlist($collations, $field["collation"]) . '</select>';
        echo ($unsigned ? "<select name='$key" . "[unsigned]'" . (!$field["type"] || ereg('((^|[^o])int|float|double|decimal)$', $field["type"]) ? "" : " class='hidden'") . '><option>' . optionlist($unsigned, $field["unsigned"]) . '</select>' : '');
        echo (isset($field['on_update']) ? "<select name='$key" . "[on_update]'" . ($field["type"] == "timestamp" ? "" : " class='hidden'") . '>' . optionlist(array("" => "(" . lang('ON UPDATE') . ")", "CURRENT_TIMESTAMP"), $field["on_update"]) . '</select>' : '');
index 10dd68d7c7ce3a1a7974dfe6b1b796abfd9912d6..4fc0233c0b5335a1280b1b9a73c5d4fb4c72fa7f 100644 (file)
@@ -358,6 +358,7 @@ function editingTypeChange(type) {
                        (/(char|binary)$/.test(lastType) && /(char|binary)$/.test(text))
                        || (/(enum|set)$/.test(lastType) && /(enum|set)$/.test(text))
                )) {
+                       el.required = /var(char|binary)$/.test(text);
                        el.value = '';
                }
                if (lastType == 'timestamp' && el.name == name + '[has_default]' && /timestamp/i.test(formField(type.form, name + '[default]').value)) {
index 9560a4418e7864c42226ad11aab76624a49d3874..259c6974df441fbf950c375d3d32f6c3edcab033 100644 (file)
@@ -1,6 +1,7 @@
 Adminer 3.7.2-dev:
 Save and continue edit by AJAX
 Add a new column in alter table on key press
+Mark length as required for strings
 PostgreSQL: Fix handling of nextval() default values
 
 Adminer 3.7.1 (released 2013-06-29):