public function YamlFormSubmissionStorage::getColumns in YAML Form 8
Get submission columns used to display results table.
Parameters
\Drupal\yamlform\YamlFormInterface|null $yamlform: A form.
\Drupal\Core\Entity\EntityInterface|null $source_entity: A form submission source entity.
\Drupal\Core\Session\AccountInterface|null $account: A user account.
Return value
array|mixed An associative array of columns keyed by name.
Overrides YamlFormSubmissionStorageInterface::getColumns
2 calls to YamlFormSubmissionStorage::getColumns()
- YamlFormSubmissionStorage::getCustomColumns in src/
YamlFormSubmissionStorage.php - Get customized submission columns used to display custom table.
- YamlFormSubmissionStorage::getDefaultColumns in src/
YamlFormSubmissionStorage.php - Get default submission columns used to display results.
File
- src/
YamlFormSubmissionStorage.php, line 320
Class
- YamlFormSubmissionStorage
- Defines the form submission storage.
Namespace
Drupal\yamlformCode
public function getColumns(YamlFormInterface $yamlform = NULL, EntityInterface $source_entity = NULL, AccountInterface $account = NULL, $include_elements = TRUE) {
$view_any = $yamlform && $yamlform
->access('submission_view_any') ? TRUE : FALSE;
$columns = [];
// Serial number.
$columns['serial'] = [
'title' => $this
->t('#'),
];
// Submission ID.
$columns['sid'] = [
'title' => $this
->t('SID'),
];
// UUID.
$columns['uuid'] = [
'title' => $this
->t('UUID'),
'default' => FALSE,
];
// Sticky (Starred/Unstarred).
if (empty($account)) {
$columns['sticky'] = [
'title' => $this
->t('Starred'),
];
// Notes.
$columns['notes'] = [
'title' => $this
->t('Notes'),
];
}
// Created.
$columns['created'] = [
'title' => $this
->t('Created'),
];
// Completed.
$columns['completed'] = [
'title' => $this
->t('Completed'),
'default' => FALSE,
];
// Changed.
$columns['changed'] = [
'title' => $this
->t('Changed'),
'default' => FALSE,
];
// Source entity.
if ($view_any && empty($source_entity)) {
$columns['entity'] = [
'title' => $this
->t('Submitted to'),
'sort' => FALSE,
];
}
// Submitted by.
if (empty($account)) {
$columns['uid'] = [
'title' => $this
->t('User'),
];
}
// Submission language.
if ($view_any && \Drupal::moduleHandler()
->moduleExists('language')) {
$columns['langcode'] = [
'title' => $this
->t('Language'),
];
}
// Remote address.
$columns['remote_addr'] = [
'title' => $this
->t('IP address'),
];
// Form.
if (empty($yamlform) && empty($source_entity)) {
$columns['yamlform_id'] = [
'title' => $this
->t('Form'),
];
}
// Form elements.
if ($yamlform && $include_elements) {
/** @var \Drupal\yamlform\YamlFormElementManagerInterface $element_manager */
$element_manager = \Drupal::service('plugin.manager.yamlform.element');
$elements = $yamlform
->getElementsFlattenedAndHasValue();
foreach ($elements as $element) {
/** @var \Drupal\yamlform\YamlFormElementInterface $element_handler */
$element_handler = $element_manager
->createInstance($element['#type']);
$columns += $element_handler
->getTableColumn($element);
}
}
// Operations.
if (empty($account)) {
$columns['operations'] = [
'title' => $this
->t('Operations'),
'sort' => FALSE,
];
}
// Add name and format to all columns.
foreach ($columns as $name => &$column) {
$column['name'] = $name;
$column['format'] = 'value';
}
return $columns;
}