function i18ncontent_form_alter in Internationalization 6
Implementation of hook_form_alter().
File
- i18ncontent/
i18ncontent.module, line 79 - Internationalization (i18n) package - translatable content type parameters
Code
function i18ncontent_form_alter(&$form, $form_state, $form_id) {
switch ($form_id) {
case 'node_type_form':
// Replace the help text default value in the node type form with data from
// i18nstrings. Help text is handled in hook_node_type() and hook_help().
$type = $form['#node_type']->type;
if ($type) {
// Fetch default language node type help
$source = i18ncontent_node_help_source($type);
// We dont need to pass the value through i18nstrings_ts()
if (isset($source->source)) {
$form['submission']['help']['#default_value'] = $source->source;
}
}
break;
case 'search_form':
// Advanced search form. Add language and localize content type names
if ($form['module']['#value'] == 'node' && !empty($form['advanced'])) {
// @todo Handle language search conditions
//$form['advanced']['language'] = _i18n_language_select();
if (!empty($form['advanced']['type'])) {
foreach ($form['advanced']['type']['#options'] as $type => $name) {
$form['advanced']['type']['#options'][$type] = i18nstrings("nodetype:type:{$type}:name", $name);
}
}
}
break;
default:
// 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'] = i18nstrings("nodetype:type:{$type}:title", $form['title']['#title']);
}
if (!empty($form['body_field']['body']['#title'])) {
$form['body_field']['body']['#title'] = i18nstrings("nodetype:type:{$type}:body", $form['body_field']['body']['#title']);
}
}
break;
}
}