function i18nsync_form_alter in Internationalization 6
Same name and namespace in other branches
- 5.3 experimental/i18nsync.module \i18nsync_form_alter()
- 5 experimental/i18nsync.module \i18nsync_form_alter()
- 5.2 experimental/i18nsync.module \i18nsync_form_alter()
Implementation of hook_form_alter().
- Vocabulary options
- Content type options
File
- i18nsync/
i18nsync.module, line 55 - Internationalization (i18n) package. Synchronization of translations
Code
function i18nsync_form_alter(&$form, $form_state, $form_id) {
// Taxonomy vocabulary form.
switch ($form_id) {
case 'node_type_form':
$type = $form['#node_type']->type;
$current = i18nsync_node_fields($type);
$disabled = $form['i18n']['#disabled'];
$form['i18n']['i18nsync_nodeapi'] = array(
'#type' => 'fieldset',
'#tree' => TRUE,
'#title' => t('Synchronize translations'),
'#collapsible' => TRUE,
'#collapsed' => !count($current),
'#description' => t('Select which fields to synchronize for all translations of this content type.'),
'#disabled' => $disabled,
);
// Each set provides title and options. We build a big checkboxes control for it to be
// saved as an array. Special themeing for group titles.
foreach (i18nsync_node_available_fields($type) as $group => $data) {
$title = $data['#title'];
if (!empty($data['#options'])) {
foreach ($data['#options'] as $field => $name) {
$form['i18n']['i18nsync_nodeapi'][$field] = array(
'#group_title' => $title,
'#title' => $name,
'#type' => 'checkbox',
'#default_value' => in_array($field, $current),
'#theme' => 'i18nsync_workflow_checkbox',
'#disabled' => $disabled,
);
$title = '';
}
}
}
break;
case 'node_delete_confirm':
// Intercept form submission so we can handle uploads, replace callback
$form['#submit'] = array_merge(array(
'i18nsync_node_delete_submit',
), $form['#submit']);
break;
case 'node_admin_content':
if (!empty($form['operation']) && $form['operation']['#value'] == 'delete') {
$form['#submit'] = array_merge(array(
'i18nsync_node_delete_submit',
), $form['#submit']);
}
break;
}
}