- Issue created by @ultrabob
- Merge request !88Use RenderInIsolation to allow render outside of a render context. β (Open) created by ultrabob
- π―π΅Japan ultrabob Japan
I've created a merge request with the suggested change in place.
- π―π΅Japan ultrabob Japan
I realized after submitting this that there is a new 3.1 release, so I tried installing that to see if it fixed my issue. It did not, but the patch applies to the new version and still works, but now I get a bunch of Warnings such as
Warning: Undefined array key "wrappers" in Drupal\custom_field\Plugin\Field\FieldFormatter\BaseFormatter->getFormattedValues() (line 477 of modules/contrib/custom_field/src/Plugin/Field/FieldFormatter/BaseFormatter.php).
and
Warning: Trying to access array offset on value of type null in template_preprocess_custom_field_item() (line 119 of modules/contrib/custom_field/custom_field.module).
so I've reverted to 3.0.x
- πΊπΈUnited States apmsooner
Thank you for the patch and insight on the wrappers issue. The latter can probably be resolved with just saving the manage display settings as theres a new setting in there but I will resolve it anyway. I will try to get this reviewed and merged in the next day or 2. I know there are other similar deprecations for some of the other field plugins so i will want to take care of them all.
- πΊπΈUnited States apmsooner
I'm unsure on this suggested fix. According to docs, renderInIsolation sounds like it should be used as a replacement for deprecated renderPlain(). In this case, it sounds like it could affect the #cache tags: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21...
The other issue is that renderInIsolation is was introduced in Drupal 10.3 so this wouldn't be backwards compatible. The suggested example for backward compatibility is here: https://www.drupal.org/node/3407994#comment-15540719 β
I'm no expert on layout builder nor caching as it can get a bit complex in these various scenarios but I just want to be careful to not break other things. I think lets keep the dialog open on this issue to help make a confident approach.
- π―π΅Japan ultrabob Japan
That all makes sense to me. I'm also not an expert on all the caching and context details here. I just know that when I tried to place the field as a block in block layout, I started getting the DWSOD. Given that this was happening with an Entity Reference field, I wonder if the core Entity Reference Field Formatter has an example we can learn from. Maybe the solution is to detect whether there is a render context, and only renderInIsolation or renderPlain when it isn't present. I appreciate you being responsive on this. It is a very cool module, that I became familiar with due to a talk at PNW Drupal Summit and then again a bit later at BADCamp last year.
- πΊπΈUnited States justcaldwell Austin, Texas
Hello! Just here to confirm that we're seeing the wrapper/offset warnings described in #4 after updating to 3.1.0. Re-saving manage display settings didn't help.
I haven't had time to investigate further. We've reverted to 3.0.x for now.
- πΊπΈUnited States apmsooner
Thanks for the confirm on wrappers. Subscribe to this bug and I'll get a patch up shortly to test out: https://www.drupal.org/project/custom_field/issues/3501250 π Warning: Undefined array key "wrappers" Active
- πΊπΈUnited States apmsooner
There's a patch now in that issue ^. Just saving manage display wouldn't have resolved it. You would need to actually edit the field settings form in manage display and then save. There's essentially a new fieldset in the field settings there that allows you to set html wrapper tags and classes to the rendered output. It's similar to the fences module but of course for these subfields.