You are here

function _formdefaults_save_form in Form Defaults 7

Same name and namespace in other branches
  1. 5.3 formdefaults.admin.inc \_formdefaults_save_form()
  2. 6.2 formdefaults.admin.inc \_formdefaults_save_form()
4 calls to _formdefaults_save_form()
formdefaults_edit_field_submit in ./formdefaults.admin.inc
formdefaults_edit_form_submit in ./formdefaults.admin.inc
formdefaults_import_submit in ./formdefaults.admin.inc
formdefaults_update_7000 in ./formdefaults.install

File

./formdefaults.admin.inc, line 30
formdefaults.admin.inc Include for formdefaults administration screen.

Code

function _formdefaults_save_form($formid, $form_array) {
  $old_form = formdefaults_getform($formid);

  // Change the input format from d6 style to d7 style.
  // Keep until D8.
  foreach ($form_array as $key => $control) {
    if (isset($control['format']) && !isset($control['input_format'])) {
      $form_array[$key]['input_format'] = $control['format'];
      unset($form_array[$key]['format']);
    }
  }
  $form_data = serialize($form_array);
  if ($form_data && $form_array) {
    if ($old_form) {
      db_update('formdefaults_forms')
        ->condition('formid', $formid)
        ->fields(array(
        'formdata' => $form_data,
      ))
        ->execute();
    }
    else {
      db_insert('formdefaults_forms')
        ->fields(array(
        'formid' => $formid,
        'formdata' => $form_data,
      ))
        ->execute();
    }
  }
  else {
    _formdefaults_delete_form($formid);
  }
}