Double click doesn't correct path

Created on 2 June 2018, over 6 years ago
Updated 20 September 2024, 4 months ago

When double clicking to add an event on the calendar the path isn't stripped back to the correct value. For example, my calendar is displayed in mysite.com/group/1/calendar. If I click add event I correctly go to

mysite.com/fullcalendar-view-event-add?type=bookings&start_field=field_start_date&end_field=field_end_date&destination=/group/1/calendar

However, if I double click on a date to add an event the link is to

mysite.com/group/1/node/add/bookings?start=2018-06-16&start_field=field_start_date

instead of

mysite.com/node/add/bookings?start=2018-06-16&start_field=field_start_date

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

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

    Similar issue. I have a custom entity type mentor_session and the correct add link is /ns-entity/add/mentor_session
    But double clicking in a day opens /add/%7Bns_entity_type%7D?start=2024-09-03&start_field=field_session_date. Is there a way to override this?

  • πŸ‡¦πŸ‡ΊAustralia mingsong πŸ‡¦πŸ‡Ί

    The bundle type is specified in the following line

    https://git.drupalcode.org/project/fullcalendar_view/-/blob/5.x/src/Full...

    And there is a setting to specify the 'Bundle type' to be created.

    But it works with Node entity. Not sure about how it works with your custom entity type.

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

    Ok, thanks I'll check how we are defining that in our entity as I do have the event bundle selected.

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

    I think it's because for the create link it needs "_type"

    Updating line 100 to this solved it for me.

          if (isset($entity_links['add-form'])) {
            $add_form = str_replace('{' . $entity_type->id() . '_type}', $event_bundle_type, $entity_links['add-form']);
          }
          elseif (isset($entity_links['add-page'])) {
            $add_form = str_replace('{' . $entity_type->id() . '_type}', $event_bundle_type, $entity_links['add-page']);
          }
    

    However the link is missing the site domain for me still open it opens in a new window.
    http://ns-entity/add/mentor_session?start=2024-09-10

  • Merge request !805.x β†’ (Open) created by jphelan
  • πŸ‡ΊπŸ‡ΈUnited States jphelan

    This patch addresses both for me.

  • Pipeline finished with Success
    4 months ago
    Total: 188s
    #287571
  • πŸ‡¦πŸ‡ΊAustralia mingsong πŸ‡¦πŸ‡Ί

    I don't know why your custom entity need the '_type' at the end.

    Let me take the Media entity from core as an example.

    https://git.drupalcode.org/project/drupal/-/blob/10.3.x/core/modules/med...

    The '_type' suffix is not mentioned in the Drupal entity API β†’ , if we hard-code this in a contribute module, it won't work for others.

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

    Both the links you sent show "_type" added after the entity type name for the add form links. Because those links contain the entity type name link /node/add/article or /node/add/page instead of the entity id like canonical and edit-form links.
    https://www.drupal.org/docs/drupal-apis/entity-api/introduction-to-entity-api-in-drupal-8#s-full-handlers-example β†’

    $entity_type->id() returns the entity type name like "node" or "commerce_product" so the str_replace in line 100 is looking for {commerce_product} instead of {commerce_product_type} to replace in add-form link. I just tested with a view of commerce_product entities and it works with the patch and does not work correctly without it.

  • Pipeline finished with Success
    4 months ago
    Total: 138s
    #288364
Production build 0.71.5 2024