Bug #3187422 Form validation and submission

This commit is contained in:
Marc Delisle
2011-03-06 08:30:51 -05:00
parent 1b94d12c3e
commit dfa4668fe6
2 changed files with 80 additions and 64 deletions

View File

@@ -1738,7 +1738,7 @@ $(document).ready(function() {
*
*/
// .live() must be called after a selector, see http://api.jquery.com/live
$("#create_table_form.ajax input[name=do_save_data]").live('click', function(event) {
$("#create_table_form input[name=do_save_data]").live('click', function(event) {
event.preventDefault();
/**
@@ -1746,6 +1746,17 @@ $(document).ready(function() {
*/
var $form = $("#create_table_form");
/*
* First validate the form; if there is a problem, avoid submitting it
*
* checkTableEditForm() needs a pure element and not a jQuery object,
* this is why we pass $form[0] as a parameter (the jQuery object
* is actually an array of DOM elements)
*/
if (checkTableEditForm($form[0], $form.find('input[name=orig_num_fields]').val())) {
// OK, form passed validation step
if ($form.hasClass('ajax')) {
PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
if (! $form.find('input:hidden').is('#ajax_request_hidden')) {
$form.append('<input type="hidden" id="ajax_request_hidden" name="ajax_request" value="true" />');
@@ -1806,11 +1817,17 @@ $(document).ready(function() {
if (window.parent && window.parent.frame_navigation) {
window.parent.frame_navigation.location.reload();
}
}
else {
} else {
$('#properties_message').html(data.error);
}
}) // end $.post()
} // end if ($form.hasClass('ajax')
else {
// non-Ajax submit
$form.append('<input type="hidden" name="do_save_data" value="save" />');
$form.submit();
}
} // end if (checkTableEditForm() )
}) // end create table form (save)
/**

View File

@@ -774,8 +774,7 @@ if ($action == 'tbl_create.php') {
?>
<fieldset class="tblFooters">
<input type="submit" name="do_save_data" value="<?php echo __('Save'); ?>"
onclick="return checkTableEditForm(this.form, <?php echo $num_fields; ?>)" />
<input type="submit" name="do_save_data" value="<?php echo __('Save'); ?>" />
<?php if ($action == 'tbl_create.php' || $action == 'tbl_addfield.php') { ?>
<?php echo __('Or'); ?>
<?php echo sprintf(__('Add %s column(s)'), '<input type="text" id="added_fields" name="added_fields" size="2" value="1" onfocus="this.select()" />'); ?>