You are here

function commons_documents_form_commons_bw_partial_node_form_alter in Drupal Commons 7.3

Implements hook_form_FROM_ID_alter().

File

modules/commons/commons_documents/commons_documents.module, line 25

Code

function commons_documents_form_commons_bw_partial_node_form_alter(&$form, &$form_state) {
  if (empty($form['#entity']) || $form['#entity']->type != 'document') {
    return;
  }
  $form['title']['#markup'] = t('Create a document');
  $language = $form['body']['#language'];
  $form['body'][$language][0]['#title_display'] = 'invisible';
  $form['body'][$language][0]['#required'] = TRUE;
  $form['body'][$language][0]['#placeholder'] = t('Describe the document');
  $form['body'][$language][0]['#resizable'] = FALSE;

  // Set fields as hideable so the forms can be compacted.
  $form['body']['#attributes']['class'][] = 'trigger-field';
  foreach (array(
    'field_image',
    'og_group_ref',
    'field_document_file',
    'actions',
  ) as $field) {
    if (isset($form[$field])) {
      $form[$field]['#attributes']['class'][] = 'hideable-field';
    }
  }
  $form['#pre_render'][] = 'commons_documents_form_commons_bw_partial_node_form_after_build';
}