public function LingotekManagementFormBase::buildForm in Lingotek Translation 3.1.x
Same name and namespace in other branches
- 8.2 src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::buildForm()
- 4.0.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::buildForm()
- 3.0.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::buildForm()
- 3.2.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::buildForm()
- 3.3.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::buildForm()
- 3.4.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::buildForm()
- 3.5.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::buildForm()
- 3.6.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::buildForm()
- 3.7.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::buildForm()
- 3.8.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::buildForm()
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides FormInterface::buildForm
2 calls to LingotekManagementFormBase::buildForm()
- LingotekJobManagementContentEntitiesForm::buildForm in src/
Form/ LingotekJobManagementContentEntitiesForm.php - Form constructor.
- LingotekManagementRelatedEntitiesForm::buildForm in src/
Form/ LingotekManagementRelatedEntitiesForm.php - Form constructor.
2 methods override LingotekManagementFormBase::buildForm()
- LingotekJobManagementContentEntitiesForm::buildForm in src/
Form/ LingotekJobManagementContentEntitiesForm.php - Form constructor.
- LingotekManagementRelatedEntitiesForm::buildForm in src/
Form/ LingotekManagementRelatedEntitiesForm.php - Form constructor.
File
- src/
Form/ LingotekManagementFormBase.php, line 207
Class
- LingotekManagementFormBase
- Form for bulk management of content.
Namespace
Drupal\lingotek\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
if ($redirect = $this
->checkSetup()) {
return $redirect;
}
$temp_store = $this->tempStoreFactory
->get($this
->getTempStorageFilterKey());
$labelFilter = $temp_store
->get('label');
$bundleFilter = $temp_store
->get('bundle');
$jobFilter = $temp_store
->get('job');
$documentIdFilter = $temp_store
->get('document_id');
$entityIdFilter = $temp_store
->get('entity_id');
$sourceLanguageFilter = $temp_store
->get('source_language');
$sourceStatusFilter = $temp_store
->get('source_status');
$targetStatusFilter = $temp_store
->get('target_status');
$profileFilter = $temp_store
->get('profile');
// Add the filters if any.
$filters = $this
->getFilters();
if (!empty($filters)) {
$form['filters'] = [
'#type' => 'details',
'#title' => $this
->t('Filter'),
'#open' => TRUE,
'#weight' => 5,
'#tree' => TRUE,
];
$form['filters']['wrapper'] = [
'#type' => 'container',
'#attributes' => [
'class' => [
'form--inline',
'clearfix',
],
],
];
foreach ($filters as $filter_id => $filter) {
$form['filters']['wrapper'][$filter_id] = $filter;
}
// Advanced filters
$form['filters']['advanced_options'] = [
'#type' => 'container',
'#attributes' => [
'class' => [
'form--inline',
'clearfix',
],
],
];
$form['filters']['advanced_options'] = [
'#type' => 'details',
'#title' => $this
->t('Show advanced options'),
'#title_display' => 'before',
'#attributes' => [
'class' => [
'form--inline',
'clearfix',
],
],
];
$form['filters']['advanced_options']['document_id'] = [
'#type' => 'textfield',
'#size' => 35,
'#title' => $this
->t('Document ID'),
'#description' => $this
->t('You can indicate multiple comma-separated values.'),
'#default_value' => $documentIdFilter,
];
$form['filters']['advanced_options']['entity_id'] = [
'#type' => 'textfield',
'#title' => $this
->t('Entity ID'),
'#description' => $this
->t('You can indicate multiple comma-separated values.'),
'#size' => 35,
'#default_value' => $entityIdFilter,
];
$form['filters']['advanced_options']['source_language'] = [
'#type' => 'select',
'#title' => $this
->t('Source language'),
'#options' => [
'' => $this
->t('All languages'),
] + $this
->getAllLanguages(),
'#default_value' => $sourceLanguageFilter,
];
$form['filters']['advanced_options']['source_status'] = [
'#type' => 'select',
'#title' => $this
->t('Source Status'),
'#default_value' => $sourceStatusFilter,
'#options' => [
'' => $this
->t('All'),
'UPLOAD_NEEDED' => $this
->t('Upload Needed'),
Lingotek::STATUS_CURRENT => $this
->t('Current'),
Lingotek::STATUS_IMPORTING => $this
->t('Importing'),
Lingotek::STATUS_EDITED => $this
->t('Edited'),
Lingotek::STATUS_CANCELLED => $this
->t('Cancelled'),
Lingotek::STATUS_ERROR => $this
->t('Error'),
],
];
$form['filters']['advanced_options']['target_status'] = [
'#type' => 'select',
'#title' => $this
->t('Target Status'),
'#default_value' => $targetStatusFilter,
'#options' => [
'' => $this
->t('All'),
Lingotek::STATUS_CURRENT => $this
->t('Current'),
Lingotek::STATUS_EDITED => $this
->t('Edited'),
Lingotek::STATUS_PENDING => $this
->t('In Progress'),
Lingotek::STATUS_READY => $this
->t('Ready'),
Lingotek::STATUS_INTERMEDIATE => $this
->t('Interim'),
Lingotek::STATUS_REQUEST => $this
->t('Not Requested'),
Lingotek::STATUS_CANCELLED => $this
->t('Cancelled'),
Lingotek::STATUS_ERROR => $this
->t('Error'),
],
];
$form['filters']['advanced_options']['profile'] = [
'#type' => 'select',
'#title' => $this
->t('Profile'),
'#options' => [
'' => $this
->t('All'),
] + $this->lingotekConfiguration
->getProfileOptions(),
'#multiple' => TRUE,
'#default_value' => $profileFilter,
];
// Filter actions
$form['filters']['actions'] = [
'#type' => 'container',
'#attributes' => [
'class' => [
'clearfix',
],
],
];
$form['filters']['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Filter'),
'#submit' => [
'::filterForm',
],
];
$form['filters']['actions']['reset'] = [
'#type' => 'submit',
'#value' => $this
->t('Reset'),
'#submit' => [
'::resetFilterForm',
],
];
}
// Add the bulk operations if any.
$options = $this
->getBulkOptions();
if (!empty($options)) {
$form['options'] = [
'#type' => 'details',
'#title' => $this
->t('Bulk document management'),
'#open' => TRUE,
'#attributes' => [
'class' => [
'container-inline',
],
],
'#weight' => 10,
];
foreach ($options as $id => $component) {
$form['options'][$id] = $component;
}
}
// Add the headers.
$headers = $this
->getHeaders();
// Get all the entities that need to be displayed.
$entities = $this
->getFilteredEntities();
// Generate the rows based on those entities.
$rows = [];
if (!empty($entities)) {
$rows = $this
->getRows($entities);
}
$pager = $this
->getPager();
if (!empty($pager)) {
$form['pager'] = [
'#type' => 'pager',
'#weight' => 50,
];
$form['items_per_page'] = $pager;
}
$form['table'] = [
'#header' => $headers,
'#options' => $rows,
'#empty' => $this
->t('No content available'),
'#type' => 'tableselect',
'#weight' => 30,
];
$form['#attached']['library'][] = 'lingotek/lingotek';
$form['#attached']['library'][] = 'lingotek/lingotek.manage';
return $form;
}