$class = 'add';
    $text = get_lang('CreateSurvey');
    $form->addButtonCreate(get_lang('CreateSurvey'), 'submit_survey');
}
// Setting the rules
if ($_GET['action'] == 'add') {
    $form->addRule('survey_code', get_lang('ThisFieldIsRequired'), 'required');
    $form->addRule('survey_code', '', 'maxlength', 20);
}
$form->addRule('survey_title', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('start_date', get_lang('InvalidDate'), 'date');
$form->addRule('end_date', get_lang('InvalidDate'), 'date');
$form->addRule(array('start_date', 'end_date'), get_lang('StartDateShouldBeBeforeEndDate'), 'date_compare', 'lte');
// Setting the default values
$form->setDefaults($defaults);
// The validation or display
if ($form->validate()) {
    // Exporting the values
    $values = $form->getSubmitValues();
    // Storing the survey
    $return = SurveyManager::store_survey($values);
    // Redirecting to the survey page (whilst showing the return message)
    header('location: ' . api_get_path(WEB_CODE_PATH) . 'survey/survey.php?survey_id=' . $return['id'] . '&' . api_get_cidreq());
    exit;
} else {
    // Displaying the header
    Display::display_header($tool_name);
    $form->display();
}
// Footer
Display::display_footer();