Пример #1
0
    $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->exportValues();
    // Storing the survey
    $return = survey_manager::store_survey($values);

    /* // Deleting the shared survey if the survey is getting unshared (this only happens when editing)
      if (is_numeric($survey_data['survey_share']) && $values['survey_share']['survey_share'] == 0 && $values['survey_id'] != '') {
      survey_manager::delete_survey($survey_data['survey_share'], true);
      }
      // Storing the already existing questions and options of a survey that gets shared (this only happens when editing)
      if ($survey_data['survey_share'] == 0 && $values['survey_share']['survey_share'] !== 0 && $values['survey_id'] != '') {
      survey_manager::get_complete_survey_structure($return['id']);
      }
     */
    if ($return['type'] == 'error') {
        // Display the error
        Display::display_error_message(get_lang($return['message']), false);

        // Displaying the header