function tmgmt_local_task_form in Translation Management Tool 7
Entity API form the local task entity.
File
- translators/
tmgmt_local/ includes/ tmgmt_local.pages.inc, line 24 - Provides page and forms callbacks.
Code
function tmgmt_local_task_form($form, &$form_state, TMGMTLocalTask $task, $op = 'edit') {
$wrapper = entity_metadata_wrapper('tmgmt_local_task', $task);
// Set the title of the page to the label and the current status of the task.
drupal_set_title(t('@label (@status)', array(
'@label' => $task
->label(),
'@status' => $wrapper->status
->label(),
)));
// Check if the translator entity is completely new or not.
$old = empty($task->is_new) && $op != 'clone';
$form['title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#default_value' => $task->title,
'#access' => user_access('administer tmgmt') || user_access('administer translation tasks'),
);
$form['status'] = array(
'#type' => 'select',
'#title' => t('Status'),
'#options' => tmgmt_local_task_statuses(),
'#default_value' => $wrapper->status
->value(),
'#access' => user_access('administer tmgmt') || user_access('administer translation tasks'),
);
$translators = tmgmt_local_translators($task
->getJob()->source_language, array(
$task
->getJob()->target_language,
));
$form['tuid'] = array(
'#title' => t('Assigned'),
'#type' => 'select',
'#options' => $translators,
'#empty_option' => t('- Select user -'),
'#default_value' => $task->tuid,
'#access' => user_access('administer tmgmt') || user_access('administer translation tasks'),
);
if ($view = views_get_view('tmgmt_local_task_items')) {
$form['items'] = array(
'#type' => 'item',
'#title' => $view
->get_title(),
'#prefix' => '<div class="tmgmt-local-task-items">',
'#markup' => $view
->preview('block', array(
$task->tltid,
)),
'#attributes' => array(
'class' => array(
'tmgmt-local-task-items',
),
),
'#suffix' => '</div>',
'#weight' => 10,
);
}
// Add the buttons and action links.
$form['actions']['#type'] = 'actions';
$form['actions']['#access'] = user_access('administer tmgmt') || user_access('administer translation tasks');
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save task'),
);
if ($old) {
$form['actions']['delete'] = array(
'#type' => 'submit',
'#value' => t('Delete'),
'#redirect' => 'translate/' . $task->tltid . '/delete',
// Don't run validations, so the user can always delete the job.
'#limit_validation_errors' => array(),
);
}
return $form;
}