Document how to create custom forms to create polls

Created on 21 January 2023, over 1 year ago
Updated 13 March 2024, 4 months ago

If the "Use the administration theme when editing or creating content" checkbox is not set on /admin/appearance, Poll module still uses the admin theme for creating new polls, if the user role has permission to view the admin theme.

Since the main purpose of that "...when editing or creating" checkbox is allow roles to use the default site theme for creating/editing nodes even if they use admin for other back office screens, can Poll follow that checkbox and behave the way node/add does?

Or maybe make it an option at /admin/config/content/poll where there are currently no settings?

If there are reasons to not do that, can you point me in the right direction for customizing that in my projects? ... maybe there is alternative way to tell Drupal to use the default theme for creating new items for a specified entity type?

πŸ“Œ Task
Status

Active

Version

2.0

Component

Documentation

Created by

πŸ‡ΊπŸ‡ΈUnited States aharown07

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @aharown07
  • πŸ‡§πŸ‡ͺBelgium BramDriesen Belgium πŸ‡§πŸ‡ͺ

    I think this is because all the poll create/edit/update routes are defined as admin routes. Hence why the admin theme is being used.

    I think if you want to create a form for other users to create polls you would be best off to create a custom form and then create the poll 1 choices programatically, and only expose the things you want to expose. I can't think of a reason for example where a user in your case would need to be able to decide if anonymous users are allowed to vote or not.

    This might be a good thing to write some documentation for.

  • πŸ‡§πŸ‡ͺBelgium BramDriesen Belgium πŸ‡§πŸ‡ͺ

    You can probably also do this with a custom form mode, and then override the theme setting. But I haven't tried this yet.

  • πŸ‡ΊπŸ‡ΈUnited States aharown07

    Webform?
    It's been a while since I worked on this issue--or used Webform module, but the idea occurs to me that presenting non-admin themed form to users for making their own polls might be a good Webform use case.

    It's still not clear to me, though, why the checkbox to use the default theme shouldn't just work as expected.

    (If it helps, the use case here is a forum where users not only post comments but create nodes of the allowed type. They are also allowed to create polls to add to their nodes.)

  • πŸ‡¨πŸ‡­Switzerland Berdir Switzerland

    > It's still not clear to me, though, why the checkbox to use the default theme shouldn't just work as expected.

    The reason is that the settings is from node module and only applies to nodes, no other core entity type respects that.

    poll was a node type in D7 but not anymore in D8+.

    (I'm not saying it's a good reason, just that it's the reason. We could set the _node_operation_route option on the respective routes if we'd want to respect it)

Production build 0.69.0 2024