You are here

function formdefaults_edit_field_submit in Form Defaults 7

Same name and namespace in other branches
  1. 5.3 formdefaults.admin.inc \formdefaults_edit_field_submit()
  2. 6.2 formdefaults.admin.inc \formdefaults_edit_field_submit()

File

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

Code

function formdefaults_edit_field_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 ($_POST['op'] == 'Reset') {
    unset($formarray[$fieldname]);
  }
  else {
    if ($form_values['type'] == 'markup') {
      $formarray[$fieldname]['value'] = $form_values['value']['value'];
      $formarray[$fieldname]['input_format'] = $form_values['value']['format'];
    }
    else {
      $formarray[$fieldname]['title'] = $form_values['title'];
      $formarray[$fieldname]['description'] = $form_values['description'];
    }
    if (@$form_values['collapsible'] === '') {
      unset($formarray[$fieldname]['collapsible']);
    }
    else {
      $formarray[$fieldname]['collapsible'] = @$form_values['collapsible'];
    }
    if (@$form_values['collapsed'] === '') {
      unset($formarray[$fieldname]['collapsed']);
    }
    else {
      $formarray[$fieldname]['collapsed'] = @$form_values['collapsed'];
    }
    $formarray[$fieldname]['hide_it'] = $form_values['hide_it'];
    $formarray[$fieldname]['weight'] = $form_values['weight'];
    $formarray[$fieldname]['type'] = $form_values['type'];
  }
  _formdefaults_save_form($formid, $formarray);
  $form_state['redirect'] = 'formdefaults/' . $formid;
}