IcalFieldsWizard rows plugin doesn't understand non-entity fields

Created on 4 September 2023, over 1 year ago
Updated 5 September 2023, over 1 year ago

Problem/Motivation

My use case involves a computed LOCATION field, as well as a URL field using "link to content." Neither is rendered by the
iCal fields row wizard, because neither maps to a "real" database-stored entity field.

The URL field problem appears to be addressed, in a case-specific way, in issue 3380184 πŸ› Allow to use the "Link to Content" as link of event Fixed . This doesn't solve the general problem, though.

Steps to reproduce

The Easy Way: add a Custom Text field to your iCal view, set its output value to "hello world", and set it as the LOCATION field in
iCal Style Wizard | Settings. Since it isn't a real entity field, it quietly fails to render.

My Complicated Case: For unrelated reasons I had to implement a computed field (incl. Views Field plugin) to retrieve and format my event addresses, which live in a referenced entity and are stored as a series of sub-fields. I followed this guide: https://www.drupal.org/docs/drupal-apis/entity-api/dynamicvirtual-field-... β†’

My field works fine with standard Views output methods, but the iCal row plugin fails in the same way as it does with Custom Text- there's no field storage defined, thus the row plugin doesn't know what to do with them.

Proposed resolution

My workaround was to use the render method attached to the Field object, e.g.

$html = $this->view->field[$field_mapping['location_field']]->render($row);

I'm attaching a patch against 8.x-1.0-alpha11 to demonstrate what I did. This is merely a hack and not a complete or correct solution. I haven't done serious Drupal development in a long time and don't know anything about current norms, like whether we can always expect a field object to have a render() method, how to properly cope with its various outputs, or whether that's even the Right Way to get at styled field output from a rows plugin.

Hopefully this can help serve as a signpost towards the correct solution, for someone who knows what they're doing.

Incidentally, the blocks of code that implement these also hard-code render methods for SUMMARY, LOCATION, URL, DESCRIPTION, etc, which is the proximal cause of issues like 3261566 πŸ› No way to modify/alter/preprocess fields/rows when using wizard plugins Needs review . You'll see meddling in my diff that corrects this for my specific use case in DESCRIPTION. That should be ignored, but the underlying issue probably shouldn't be.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States stange@johnstange.net

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

Comments & Activities

  • Issue created by @stange@johnstange.net
  • πŸ‡ΊπŸ‡ΈUnited States bburg Washington D.C.

    Yeah, this issue and πŸ› No way to modify/alter/preprocess fields/rows when using wizard plugins Needs review both suffer from the underlying issue that this module circumvents a lot of the default rendering methods so we can feed entity field values to the iCalendar library, and use that for actually rendering the calendar. I'm certain there has to be a solution for for the issue that doesn't treat every scenario as a one-off, but I haven't been able to find a solution for that yet. I'm happy to review any patches that anyone wants to post, but I'm afraid I'm limited on the amount of active development I can personally do at the moment.

Production build 0.71.5 2024