View source
<?php
namespace Drupal\track_da_files\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
class TrackDaFilesTableActionForm extends FormBase {
public function getFormId() {
return 'table_action_form';
}
public function buildForm(array $form, FormStateInterface $form_state) {
$account = \Drupal::currentUser();
$admin_access = $account
->hasPermission('administer track da files');
$init_access = $account
->hasPermission('initialize tracked files displays datas');
if ($admin_access) {
$form['track_da_files_table_action']['track_da_files_export_files_datas'] = array(
'#type' => 'submit',
'#value' => $this
->t('Export datas into CSV file'),
'#submit' => array(
'track_da_files_export_files_datas_submit',
),
);
}
if ($init_access) {
$form['track_da_files_table_action']['track_da_files_clear_file_datas'] = array(
'#type' => 'details',
'#title' => $this
->t('Clear file datas'),
'#description' => $this
->t('Datas will be removed for this file.'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['track_da_files_table_action']['track_da_files_clear_file_datas']['clear'] = array(
'#type' => 'submit',
'#value' => $this
->t('Remove all datas for this file'),
'#submit' => array(
'track_da_files_clear_file_datas_submit',
),
);
}
if ($admin_access) {
$form['track_da_files_table_action']['track_da_files_export_files_datas'] = array(
'#type' => 'submit',
'#value' => $this
->t('Export datas into CSV file'),
'#submit' => array(
'track_da_files_export_files_datas_submit',
),
);
}
if ($init_access) {
$form['track_da_files_table_action']['track_da_files_clear_file_datas'] = array(
'#type' => 'details',
'#title' => $this
->t('Clear all files datas'),
'#description' => $this
->t('Datas will be cleared for all files.'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['track_da_files_table_action']['track_da_files_clear_file_datas']['clear'] = array(
'#type' => 'submit',
'#value' => $this
->t('Clear datas'),
'#submit' => array(
'track_da_files_clear_file_datas_submit',
),
);
}
return $form;
}
public function validateForm(array &$form, FormStateInterface $form_state) {
}
public function submitForm(array &$form, FormStateInterface $form_state) {
return $this
->track_da_files_clear_file_datas_submit();
}
}