function lingotek_add_workflow_settings_form in Lingotek Translation 7.6
Same name and namespace in other branches
- 7.5 lingotek.module \lingotek_add_workflow_settings_form()
1 call to lingotek_add_workflow_settings_form()
- lingotek_get_node_settings_form in ./
lingotek.module - Display the Lingotek node-settings form
File
- ./
lingotek.module, line 2591
Code
function lingotek_add_workflow_settings_form($form, $form_state, $node) {
// show workflow-change option only if there are more than one workflow and if it's an existing node
$workflows = LingotekApi::instance()
->listWorkflows();
if ($workflows && count($workflows) > 1) {
$form['lingotek']['workflow_id'] = array(
'#type' => 'select',
'#title' => t('Workflow'),
'#prefix' => '<div id="prefill-phases-div">',
'#description' => t('Choose the Workflow to associate with this content item.'),
'#default_value' => $node->lingotek['workflow_id'],
'#options' => $workflows,
'#empty_option' => '(select one)',
);
if (empty($node->nid)) {
// don't show prefill stuff on new nodes
$form['lingotek']['workflow_id']['#suffix'] = '</div>';
}
else {
// add the callback and checkbox and phase-select
$form['lingotek']['workflow_id']['#ajax'] = array(
'callback' => 'lingotek_get_change_workflow_form_callback',
'wrapper' => 'prefill-phases-div',
'method' => 'replace',
'effect' => 'fade',
);
$form['lingotek']['prefill_phases_checkbox'] = array(
'#type' => 'checkbox',
'#title' => t('Restore to a phase in the new workflow'),
'#default_value' => TRUE,
'#description' => t('Prefill the new workflow with translations from the previous workflow'),
'#states' => array(
'invisible' => array(
':input[name="lingotek[workflow_id]"]' => array(
'value' => $node->lingotek['workflow_id'],
),
),
),
);
$form['lingotek']['prefill_phase_select'] = array(
'#title' => t("Desired Prefill Phase"),
'#description' => t('Please select the highest phase which should be prefilled for the new workflow'),
'#type' => 'select',
'#states' => array(
'visible' => array(
':input[name="lingotek[workflow_id]"]' => array(
'!value' => $node->lingotek['workflow_id'],
),
array(
':input[name="lingotek[prefill_phases_checkbox]"]' => array(
'checked' => TRUE,
),
),
),
),
'#suffix' => '</div>',
);
if (isset($form_state['values']['lingotek']['workflow_id']) && $form_state['values']['lingotek']['workflow_id'] != NULL) {
$form['lingotek']['prefill_phase_select']['#options'] = lingotek_get_phases_by_workflow_id($form_state['values']['lingotek']['workflow_id']);
}
else {
$form['lingotek']['prefill_phase_select']['#options'] = array(
'-1' => '(first choose a workflow)',
);
$form['lingotek']['prefill_phase_select']['#disabled'] = TRUE;
}
}
}
return $form;
}