Hello,

In case of multiple values fields, the postProcess method of field enhancers is applied to each individual value of the field but the prepareForInput is applied to the array of values.

I will provide a patch to have the prepareForInput method also applied to each individual value of the field.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Grimreaper created an issue. See original summary.

Grimreaper’s picture

Title: Field enhancer postProcess and prepareForInput does not behave symmetrically in cas of multi-value field » Field enhancer postProcess and prepareForInput does not behave symmetrically in case of multi-value field
Assigned: Grimreaper » Unassigned
Status: Active » Needs review
FileSize
1.94 KB

Here is the patch.

Thanks for the review.

e0ipso’s picture

This patch uses the schema information to derive the field cardinality. @Grimreaper please review.

Grimreaper’s picture

Hello @e0ipso,

Thanks for the patch. Here is an updated one.

I have added a check if the field exists in the field storage definitions because otherwise there was a fatal error for computed/pseudo fields such as "path".

if (isset($field_storage_definitions[$internal_name])) {

Otherwise the patch works for me.

As I post a new patch, I don't know if I should change the status to RTBC.

  • e0ipso committed dbb3413 on 8.x-1.x authored by Grimreaper
    fix(Enhancers): Fix the prepareForInput application in multiple...
e0ipso’s picture

Status: Needs review » Fixed

Looks good to me!

Grimreaper’s picture

Thanks for the commit :)

Grimreaper’s picture

Status: Fixed » Needs review
FileSize
1.14 KB

In case of fields with cardinality > 1 with no value. $field_value is null so it raises a warning.

Don't know why I didn't see the warning before, sorry.

Here is a patch. Thanks for the review.

  • e0ipso committed 3f5f368 on 8.x-1.x authored by Grimreaper
    fix(Misc): Avoid warning when field is empty (#2884862 by Grimreaper)
    
e0ipso’s picture

Status: Needs review » Fixed

Thanks again. Please keep reporting and fixing like this! :-P

Status: Fixed » Closed (fixed)

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