You are here

function sheetnode_form_alter in Sheetnode 7

Same name and namespace in other branches
  1. 5 sheetnode.module \sheetnode_form_alter()
  2. 6 sheetnode.module \sheetnode_form_alter()
  3. 7.2 sheetnode.module \sheetnode_form_alter()

Implements hook_form_alter().

File

./sheetnode.module, line 888
Module file for the sheetnode module.

Code

function sheetnode_form_alter(&$form, $form_state, $form_id) {

  // Sheetfield settings:
  // * Insert extra template element for default values.
  if ($form_id == 'field_ui_field_edit_form' && $form['#field']['type'] == 'sheetfield') {
    $options[0] = t('- Select a template -');
    $templates = db_query("SELECT tid, name FROM {sheetnode_template}");
    foreach ($templates as $template) {
      $options[$template->tid] = $template->name;
    }
    $form['instance']['default_value_widget']['sheetfield_template'] = array(
      '#type' => 'select',
      '#title' => t('Template'),
      '#description' => t('The template to load into your new sheetfield. This setting will override the sheet above but will be overridden by the PHP code below, if any.'),
      '#options' => $options,
      '#default_value' => variable_get('sheetfield_template_' . $form['#field']['field_name'], 0),
      '#weight' => 1,
    );
    array_unshift($form['#submit'], '_sheetnode_field_ui_field_edit_form_submit');
  }
}