Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
See https://www.drupal.org/node/2621528#comment-10859088
If you create a paragraph and inside the paragraph entity type a field which is an image field that allows not 1 and not an unlimited number of items the values inside validateMultipleCount are not found.
This is easily fixable with a change to the function:
FileWidget::validateMultipleCount line 338:
$current = count(Element::children(NestedArray::getValue($form, $parents))) - 1;
to
$current = count(Element::children(NestedArray::getValue($form_state->getValues(), $parents))) - 1;
It looks like it is only used for the counter.
Comment | File | Size | Author |
---|---|---|---|
#14 | drupal_2669326_8.patch | 6.36 KB | xjm |
#10 | filewidget_inside-2669326-10-test-only.patch | 3.74 KB | johnchque |
#8 | drupal_2669326_8.patch | 6.36 KB | Xano |
Comments
Comment #2
danielbeeke CreditAttribution: danielbeeke commentedComment #3
miro_dietikerComment #4
swentel CreditAttribution: swentel commentedWondering if #2653106: Introduce SubformInterface or #2537732: PluginFormInterface must have access to the complete $form_state (introduce SubFormState for embedded forms) might solve this, and in the end paragraphs should take advantage of it.
Comment #7
jmuzz CreditAttribution: jmuzz commentedThis also affects the field collection module.
I agree with the proposed fix. The problem seems to be a mixup between #parents and #array_parents. For example, for field collections, the following change will also work:
Comment #8
XanoThe original patch does not work, because it tries to get the child elements from form state values, which is impossible.
This patch tries to stay as close as possible to the original solution (because I did not want to dig through the array structures, not because I think we necessarily must). It also fixes the test failures. It seems the original error handling and its test coverage was not very good, unless I missed something.
Comment #9
Sutharsan CreditAttribution: Sutharsan commentedThe patch works in my situation:
- Node with Paragraph field of Paragraph type with (text and) image field with 3 values.
Initial work around was to make the image field cardinality unlimited.
Comment #10
johnchqueTested manually and works fine with the patch! Let's see what happens with the test only patch. :)
Comment #12
johnchqueCool, then this fixes the problem I think
Comment #13
kasperg CreditAttribution: kasperg at Reload commentedI tested #8 on 8.1.3 and it works as well. I reviewed the code and it and looks good to me.
Comment #14
xjmThanks for providing a test-only patch!
Due to a quirk of the testing system, we need to make sure that the actual patch is the final attachment (otherwise it does not get automatically retested). So reuploading that, and saving issue credit.
Comment #17
XanoBack to RTBC as per #13.
Comment #19
XanoComment #20
catchCommitted/pushed to 8.2.x and cherry-picked to 8.1.x. Thanks!