Just a quickie. Every so often in Drupal you will come across the need to hide a form field, but can't get rid of it, because it holds a value, or you need to show it to one roll but not another, etc. In cases such as this, it is good to remember '#type' = 'value'

Thanks to Eugen Mayer for refreshing me on that.

An example would be

<?php
/**
* Implementation of hook_form_alter()
*
*/
function cool_module_form_alter(&$form, $form_state, $form_id) {
  switch (
$form_id) {
    case
'wicked_cool_form':
      if (
$form_state['pigs'] == 'fly') {
       
$form['pigs']['field_pigs_can_fly']['#type'] = 'value';
      }
    break;
  }
}
?>

Powered by Drupal, an open source content management system