summaryrefslogtreecommitdiffstats
path: root/fedora.module
blob: 9c8373ee9f123377e253a7830c4c54f470f6744b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
  // $Id$

  /**
   * Change content creation form to remove "title" field for FWN
   * beats. For that content type we will autocompute the results from
   * the issue and beat number provided through CCK.
   */

function fedora_fwnbeat_node_form_validate($form, &$form_state) {
  /**
   * This function does not do pure validation, but rather performs
   * the specific function of computing the value of a new node title
   * from a given FWN issue and beat.
   */	
  $newtitle = 'FWN ' . $form_state['values']['field_issue'][0]['value'] . ' - ' . $form_state['values']['field_beat'][0]['value'];
  form_set_value($form['title'], $newtitle, $form_state);
}

function fedora_form_fwnbeat_node_form_alter(&$form, $form_state) {
  // In the FWN beat content entry form, remove the title field
  $form['title']['#type'] = 'hidden';
  $form['title']['#value'] = NULL;
  // array_unshift() puts our custom validation function at the top.
  array_unshift($form['#validate'], 'fedora_fwnbeat_node_form_validate');
}