hasErrors() public method

Tells whether form validation failed
public hasErrors ( ) : boolean
return boolean
コード例 #1
0
 /**
  * Test for FormDisplay::hasErrors
  *
  * @return void
  */
 public function testHasErrors()
 {
     $attrErrors = new \ReflectionProperty('PMA\\libraries\\config\\FormDisplay', '_errors');
     $attrErrors->setAccessible(true);
     $this->assertFalse($this->object->hasErrors());
     $attrErrors->setValue($this->object, array(1, 2));
     $this->assertTrue($this->object->hasErrors());
 }
コード例 #2
0
     foreach ($formset as $form_name => $form) {
         $form_display->registerForm($formset_id . ': ' . $form_name, $form);
     }
 }
 $new_config = $cf->getFlatDefaultConfig();
 if (!empty($_POST['import_merge'])) {
     $new_config = array_merge($new_config, $cf->getConfigArray());
 }
 $new_config = array_merge($new_config, $config);
 $_POST_bak = $_POST;
 foreach ($new_config as $k => $v) {
     $_POST[str_replace('/', '-', $k)] = $v;
 }
 $cf->resetConfigData();
 $all_ok = $form_display->process(true, false);
 $all_ok = $all_ok && !$form_display->hasErrors();
 $_POST = $_POST_bak;
 if (!$all_ok && isset($_POST['fix_errors'])) {
     $form_display->fixErrors();
     $all_ok = true;
 }
 if (!$all_ok) {
     // mimic original form and post json in a hidden field
     include 'libraries/user_preferences.inc.php';
     $msg = Message::error(__('Configuration contains incorrect data for some fields.'));
     $msg->display();
     echo '<div class="config-form">';
     echo $form_display->displayErrors();
     echo '</div>';
     echo '<form action="prefs_manage.php" method="post">';
     echo PMA_URL_getHiddenInputs(), "\n";
コード例 #3
0
/**
 * Processes forms registered in $form_display, handles error correction
 *
 * @param FormDisplay $form_display Form to display
 *
 * @return void
 */
function PMA_Process_formset(FormDisplay $form_display)
{
    if (isset($_GET['mode']) && $_GET['mode'] == 'revert') {
        // revert erroneous fields to their default values
        $form_display->fixErrors();
        PMA_generateHeader303();
    }
    if (!$form_display->process(false)) {
        // handle form view and failed POST
        echo $form_display->getDisplay(true, true);
        return;
    }
    // check for form errors
    if (!$form_display->hasErrors()) {
        PMA_generateHeader303();
        return;
    }
    // form has errors, show warning
    $separator = PMA_URL_getArgSeparator('html');
    $page = isset($_GET['page']) ? $_GET['page'] : null;
    $formset = isset($_GET['formset']) ? $_GET['formset'] : null;
    $formset = $formset ? "{$separator}formset={$formset}" : '';
    $formId = PMA_isValid($_GET['id'], 'numeric') ? $_GET['id'] : null;
    if ($formId === null && $page == 'servers') {
        // we've just added a new server, get its id
        $formId = $form_display->getConfigFile()->getServerCount();
    }
    $formId = $formId ? "{$separator}id={$formId}" : '';
    ?>
    <div class="error">
        <h4><?php 
    echo __('Warning');
    ?>
</h4>
        <?php 
    echo __('Submitted form contains errors');
    ?>
<br />
        <a href="<?php 
    echo PMA_URL_getCommon(), $separator;
    ?>
page=<?php 
    echo $page, $formset, $formId, $separator;
    ?>
mode=revert">
            <?php 
    echo __('Try to revert erroneous fields to their default values');
    ?>
        </a>
    </div>
    <?php 
    echo $form_display->displayErrors();
    ?>
    <a class="btn" href="index.php<?php 
    echo PMA_URL_getCommon();
    ?>
">
        <?php 
    echo __('Ignore errors');
    ?>
    </a>
    &nbsp;
    <a class="btn" href="<?php 
    echo PMA_URL_getCommon() . $separator;
    ?>
page=<?php 
    echo $page . $formset . $formId . $separator;
    ?>
mode=edit">
        <?php 
    echo __('Show form');
    ?>
    </a>
    <?php 
}
コード例 #4
0
ファイル: prefs_forms.php プロジェクト: phpmyadmin/phpmyadmin
    // skip Developer form if no setting is available
    if ($form_name == 'Developer' && !$GLOBALS['cfg']['UserprefsDeveloperTab']) {
        continue;
    }
    $form_display->registerForm($form_name, $form, 1);
}
if (isset($_POST['revert'])) {
    // revert erroneous fields to their default values
    $form_display->fixErrors();
    // redirect
    $url_params = array('form' => $form_param);
    PMA_sendHeaderLocation('./prefs_forms.php' . URL::getCommonRaw($url_params));
    exit;
}
$error = null;
if ($form_display->process(false) && !$form_display->hasErrors()) {
    // save settings
    $result = PMA_saveUserprefs($cf->getConfigArray());
    if ($result === true) {
        // reload config
        $GLOBALS['PMA_Config']->loadUserPreferences();
        $tabHash = isset($_POST['tab_hash']) ? $_POST['tab_hash'] : null;
        $hash = ltrim($tabHash, '#');
        PMA_userprefsRedirect('prefs_forms.php', array('form' => $form_param), $hash);
        exit;
    } else {
        $error = $result;
    }
}
// display forms
$response = Response::getInstance();