You are here

function formdefaults_edit_submit in Form Defaults 6

Same name and namespace in other branches
  1. 5 formdefaults.module \formdefaults_edit_submit()
  2. 5.2 formdefaults.module \formdefaults_edit_submit()

File

./formdefaults.module, line 331

Code

function formdefaults_edit_submit($formid, $form_state) {
  $form_values = $form_state['values'];
  $formid = $form_values['formid'];
  $fieldname = $form_values['fieldname'];
  $formarray = formdefaults_getform($formid);
  $baseform = $formarray;

  // set the form values
  if ($form_values['type'] == 'markup') {
    $formarray[$fieldname]['value'] = $form_values['value'];
    $formarray[$fieldname]['format'] = $form_values['format'];
  }
  else {
    $formarray[$fieldname]['title'] = $form_values['title'];
    $formarray[$fieldname]['description'] = $form_values['description'];
  }
  $formarray[$fieldname]['hide_it'] = $form_values['hide_it'];
  $formarray[$fieldname]['weight'] = $form_values['weight'];
  $formdata = serialize($formarray);
  if ($baseform) {
    db_query('UPDATE {formdefaults_forms} SET formdata=\'%s\' WHERE formid=\'%s\'', $formdata, $formid);
  }
  else {
    db_query('INSERT INTO {formdefaults_forms} (formid, formdata) VALUES (\'%s\',\'%s\')', $formid, $formdata);
  }
}