As mentioned in #2008898: Replace Merge fields select options with standard Drupal tokens, I now took the path of adding property support to the merge field mapping. I noticed that the code for that already existed but was commented out 7.x code.

Same for referenced entities, I also updated that and also touched quite a bit of related code, which makes this a bit bigger but I think also less likely to fail in some weird way (e.g. the user bundle fix would as far as I see result in a fatal error on any non-user entity right now) and the has-changed logic now re-uses the mergevars populate helper function instead of duplicating part of the logic (which failed now with the new keys).

Tested with the name field, the address field for example now also shows up nicely. I also tested it with a referenced entity (filename of the user picture as I had nothing else at hand)

Allowing myself to make this major, with all those fixes and improvement I think this is a pretty big improvement.

Comments

Berdir created an issue. See original summary.

berdir’s picture

StatusFileSize
new11.7 KB
berdir’s picture

Status: Active » Needs review
berdir’s picture

Fixed an error when a field with field properties when the field is empty.

berdir’s picture

Another small change, this forces the values we send to be strings. This was a problem for me e.g. in migrations where some users had NULL as value that was set and not an empty string. That resulted in errors like this: a:1:{i:0;O:8:"stdClass":2:{s:5:"field";s:18:"merge_fields.LNAME";s:7:"message";s:57:"Data did not match any of the schemas described in anyOf.";}}"

Not sure if the @todo is relevant or if always sending a string is fine. Probably it is.

  • ruscoe committed 7264af4 on 8.x-1.x authored by Berdir
    Issue #2908547 by Berdir: Finish port of merge field population logic
    
ruscoe’s picture

Status: Needs review » Fixed

Thank you, Berdir. This works perfectly for me. I'll update the issues that reference this one to let people know a patch has been committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.