Contributions API

Calling all Drupal developers!

Help us get this on the first page of Digg. DIGG NOW!

Modules in 6

i18ncontent_form_alter

Definition

i18ncontent_form_alter(&$form, $form_state, $form_id)
contributions/i18n/i18ncontent/i18ncontent.module, line 70

Description

Implementation of hook_form_alter()

Code

<?php
function i18ncontent_form_alter(&$form, $form_state, $form_id) {
  // Translate field names for title and body for the node edit form
  if (isset($form['#id']) && $form['#id'] == 'node-form') {
    $type = $form['#node']->type;
    if (!empty($form['title']['#title'])) {
      $form['title']['#title'] = tt("nodetype:$type:title", $form['title']['#title']);
    }
    if (!empty($form['body_field']['body']['#title'])) {
      $form['body_field']['body']['#title'] = tt("nodetype:$type:body", $form['body_field']['body']['#title']);
    }
  }
  // Handle submissions for node_type_forms
  if ($form_id == 'node_type_form') {
    $type = $form['#node_type']->type;
    // We are using default language for this
    $language = language_default('language');
    // If we are creating a new one, just add the submission hook
    if ($type) {
      //$form['description']['#default_value'] = ts("nodetype:$type:description");
      $form['submission']['help']['#default_value'] = ts("nodetype:$type:help", $form['submission']['help']['#default_value'], $language);
    } 
    $form['#submit'] = array_merge(array('i18ncontent_form_submit'), $form['#submit']);
  }
}
?>