You are here

8 February 2013

This snippet shows how to remove form elements in Drupal. I am using hook_form_alter and access parameter from form api.

Source code viewer
  1. /**
  2.  * Implements hook_form_alter().
  3.  */
  4. function HOOK_form_alter(&$form, &$form_state, $form_id) {
  5. // Remove fields with only functional purpose, not for human eyes.
  6. if (isset($form['field_date'])) {
  7. $form['field_date']['#access'] = FALSE;
  8. $form['field_count']['#access'] = FALSE;
  9. }
  10. }
Programming Language: PHP