When using a View to control access to prior Submissions, it would be nice to disable the "Results" features within the standard UI. As currently implemented, the "Results" feature is enabled when you allow users to view prior Submissions. You have to enable that access permission for the views to be able to see the data.

Thanks!

-Bart

Comments

bartschaerrer created an issue. See original summary.

jrockowitz’s picture

Are you looking for way to hide the 'Results' tab?

bartschaerrer’s picture

Yes. And, ideally, the related Results-type features like Previous/Next submission links when viewing a submission. If I'm providing the desired navigation through a View, I would prefer the end user not get confused by another path to access the submissions. Just a thought...

Thanks for the consideration!

bartschaerrer’s picture

I'm trying to use forms in a way similar to articles. Once posted, I'd like all authenticated users to be able to review them. But I'd like to control how they do that. The default Results features are geared a bit too far towards system admins for my audience.

jrockowitz’s picture

Have you tried to overwrite the default Results path with the View's path? In D6 and D7 this was possible, I am not sure about D8.

bartschaerrer’s picture

I'll check into that. Thanks!

jrockowitz’s picture

Status: Active » Needs review

I checked and Views can't overwrite the tabs, you are going to have to write some custom code and place it in a custom module.

A few approaches..

- Use hook_menu_links_discovered_alter() to completely remove 'Results' and 'Submission' callbacks
- Use hook_local_tasks_alter() to alter the tabs.
- Use hook_menu_local_tasks_alter() to alter the tabs and remove the 'Table' and 'Submission' tab. (See below code example)

/**
 * Implements hook_menu_local_tasks_alter().
 */
function yamlform_examples_menu_local_tasks_alter(&$data, $route_name) {
  if (strpos($route_name, 'entity.yamlform.results_') === 0) {
    if (isset($data['tabs'])) {
      // Update the main tabs and point the 'Results' tab to the 'Download'
      // page.
      if (isset($data['tabs'][0])) {
        /** @var \Drupal\Core\Url $url */
        $url = $data['tabs'][0]['entity.yamlform.results']['#link']['url'];
        $data['tabs'][0]['entity.yamlform.results']['#link']['url'] = Url::fromRoute(
          'entity.yamlform.results_export',
          $url->getRouteParameters(),
          $url->getOptions()
        );
      }
      // Remove the 'Submissions' and 'Table' for the second row of tabs.
      // IMPORTANT: The 'Submissions' and 'Table' page are still accesible via
      // their direct URL.
      if (isset($data['tabs'][1])) {
        unset(
          $data['tabs'][1]['entity.yamlform.results_submissions'],
          $data['tabs'][1]['entity.yamlform.results_table']
        );
      }
    }
  }
}
fenstrat’s picture

Project: YAML Form » Webform
Version: 8.x-1.0-beta23 » 8.x-5.x-dev
jrockowitz’s picture

Status: Needs review » Closed (won't fix)