You are here

function formdefaults_edit_form in Form Defaults 7

Same name and namespace in other branches
  1. 5.3 formdefaults.admin.inc \formdefaults_edit_form()
  2. 6.2 formdefaults.admin.inc \formdefaults_edit_form()
1 string reference to 'formdefaults_edit_form'
formdefaults_edit in ./formdefaults.module

File

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

Code

function formdefaults_edit_form() {
  $formid = arg(1);
  $fieldname = arg(2);
  drupal_set_title(t('Edit Form @formid', array(
    '@formid' => $formid,
  )));

  // Load the form
  $data = formdefaults_getform($formid);
  $fields = array();
  $form['formid'] = array(
    '#type' => 'value',
    '#value' => $formid,
  );
  foreach ($data as $f => $field) {
    if (strpos($f, '#') !== 0) {
      $t = @$field['title'] ? ' - ' . @$field['title'] : '';
      $fields[$f] = l($f . $t, 'formdefaults/' . $formid . '/' . urlencode($f));
    }
  }
  $form['fields'] = array(
    '#type' => 'checkboxes',
    '#title' => 'Overriden Fields',
    '#options' => $fields,
  );
  $form['add'] = array(
    '#type' => 'fieldset',
    '#title' => 'Add Fields',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $types = array(
    'markup' => 'Markup',
    'fieldset' => 'Collapsed fieldset with markup ',
  );
  $form['add']['field_type'] = array(
    '#type' => 'select',
    '#title' => 'Type',
    '#options' => $types,
    '#description' => t('Choose Markup to add a place for instructions that are always seen.  Choose collapsed fieldset to add instructions inside an expandable box'),
  );

  // Weight of
  $weight_range = range(-50, 50);
  $weights = array(
    'unset' => 'unset',
  );
  foreach ($weight_range as $weight) {
    $weights[(string) $weight] = (string) $weight;
  }
  $form['add']['weight'] = array(
    '#type' => 'select',
    '#title' => 'Weight',
    '#options' => $weights,
    '#default_value' => -49,
    '#description' => 'Controls placement within the form, -49 is a good header value or 50 is usually a good footer value',
  );
  $form['add']['add_submit'] = array(
    '#type' => 'submit',
    '#value' => 'Add',
  );
  $form['reset'] = array(
    '#type' => 'submit',
    '#value' => 'Reset Selected',
  );
  return $form;
}