Fixed: Not selecting a datalabel used to issue a notice(undefined offset)
[phpmyadmin/ammaryasirr.git] / setup / lib / form_processing.lib.php
blob10c368c0ef0a70da1141cac03f0b4684b2940d9f
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Formset processing library
6 * @package phpMyAdmin-setup
7 */
9 /**
10 * Processes forms registered in $form_display, handles error correction
12 * @param FormDisplay $form_display
14 function process_formset(FormDisplay $form_display)
16 if (filter_input(INPUT_GET, 'mode') == 'revert') {
17 // revert erroneous fields to their default values
18 $form_display->fixErrors();
19 // drop post data
20 header('HTTP/1.1 303 See Other');
21 header('Location: index.php');
22 exit;
24 if (!$form_display->process(false)) {
25 // handle form view and failed POST
26 $form_display->display(true, true);
27 } else {
28 // check for form errors
29 if ($form_display->hasErrors()) {
30 // form has errors, show warning
31 $separator = PMA_get_arg_separator('html');
32 $page = filter_input(INPUT_GET, 'page');
33 $formset = filter_input(INPUT_GET, 'formset');
34 $formset = $formset ? "{$separator}formset=$formset" : '';
35 $id = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT);
36 if ($id === null && $page == 'servers') {
37 // we've just added a new server, get it's id
38 $id = ConfigFile::getInstance()->getServerCount();
40 $id = $id ? "{$separator}id=$id" : '';
42 <div class="error">
43 <h4><?php echo __('Warning') ?></h4>
44 <?php echo __('Submitted form contains errors') ?><br />
45 <a href="?page=<?php echo $page . $formset . $id . $separator ?>mode=revert"><?php echo __('Try to revert erroneous fields to their default values') ?></a>
46 </div>
47 <?php $form_display->displayErrors() ?>
48 <a class="btn" href="index.php"><?php echo __('Ignore errors') ?></a>
49 &nbsp;
50 <a class="btn" href="?page=<?php echo $page . $formset . $id . $separator ?>mode=edit"><?php echo __('Show form') ?></a>
51 <?php
52 } else {
53 // drop post data
54 header('HTTP/1.1 303 See Other');
55 header('Location: index.php');
56 exit;