You are here

function fillpdf_field_edit_submit in FillPDF 6

Same name and namespace in other branches
  1. 5 fillpdf.module \fillpdf_field_edit_submit()
  2. 7.2 fillpdf.admin.inc \fillpdf_field_edit_submit()
  3. 7 fillpdf.admin.inc \fillpdf_field_edit_submit()

File

./fillpdf.admin.inc, line 667
Allows mappings of PDFs to site content

Code

function fillpdf_field_edit_submit($form, &$form_state) {
  if ($form['#pdf_field']) {
    if ($form_state['values']['op'] == t('Delete')) {
      $form_state['redirect'] = 'admin/content/fillpdf/' . $form['#pdf_form']->fid . '/delete/' . $form['#pdf_field']->pdf_key;
      return;
    }
    $edit_field = (object) $form_state['values'];
    fillpdf_update_field($form['#pdf_form'], $edit_field, $form['#pdf_field']->pdf_key);
  }
  else {

    //add a new field
    $edit_field = (object) $form_state['values'];
    db_query("INSERT INTO {fillpdf_fields} (fid, label, pdf_key, value, replacements) VALUES(%d, '%s', '%s', '%s', '%s')", $form['#pdf_form']->fid, $form_state['values']['label'], $form_state['values']['pdf_key'], empty($form_state['values']['value']) ? '' : $form_state['values']['value'], $form_state['values']['replacements']);
  }
  $form_state['redirect'] = 'admin/content/fillpdf/' . $form['#pdf_form']->fid;
}