Problem/Motivation

The image effect form validation passes the control to the effect plugin to validate the form values. This is done by instantiating a new form state that is passd to the plugin form validator. In case of errors the errors are registered to the new virtual form state but are not passed back to the main effect form.

Proposed resolution

Copy the form validation errors back to the main effect form state.

Remaining tasks

None.

User interface changes

None.

API changes

None.

Data model changes

None.

Comments

mallezie created an issue. See original summary.

toniteof’s picture

Assigned: Unassigned » toniteof

I am working on it.

toniteof’s picture

Status: Active » Needs review
StatusFileSize
new2.73 KB

Same problem with background color validation in style rotate effect.
We should pass original $form_state through for validation, to get error message on right place.

gnuget’s picture

Using this patch doesn't imply to we will need to change the way to access to the $form_state values for any contrib image filter?

Because we will need to use $data=$form_state->getValue('data'); $bgcolor = $data['bgcolor']; instead of $form_state->getValue('bgcolor'); etc.

claudiu.cristea’s picture

StatusFileSize
new2.31 KB
new1.48 KB

@toniteof thank you but the fix is not exactly that. Two patches, one that is only the test to prove the bug.

claudiu.cristea’s picture

Issue summary: View changes

IS fix.

claudiu.cristea’s picture

Component: image system » image.module
Assigned: toniteof » Unassigned

Summary...

Status: Needs review » Needs work

The last submitted patch, 5: 2645784-4-test-only.patch, failed testing.

claudiu.cristea’s picture

Status: Needs work » Needs review

Setting back to NR. The main patch passed, the test-only failed.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Nice, this fixes a problem and adds some test coverage

claudiu.cristea’s picture

Title: Validation message not shown on image style scale effect » Error validation messages produced by effects plugin not shown

Fixing title.

mallezie’s picture

StatusFileSize
new29.89 KB

Thanks, this works as expected.

screenshot

This can also be used in sub contrib image styles as in https://www.drupal.org/project/image_max_size_crop (where i found the bug) and also fixes it for there.

Patch itself looks great! Nothing to notice on it. And thanks for the test! So RTBC + 1

claudiu.cristea’s picture

Title: Error validation messages produced by effects plugin not shown » Error validation messages produced by image effect plugins not shown
tim.plunkett’s picture

Status: Reviewed & tested by the community » Needs work

This is a symptom of #2537732: PluginFormInterface must have access to the complete $form_state (introduce SubFormState for embedded forms), which if fixed properly, would make this obsolete.
If this is committed as a workaround, it should at least reference it in an @todo.

claudiu.cristea’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new2.39 KB
new780 bytes

I'm setting this back to RTBC because I only added a @todo comment. It will be up to core committers to commit this as a temporary solution till #2537732: PluginFormInterface must have access to the complete $form_state (introduce SubFormState for embedded forms) lands.

tim.plunkett’s picture

My worry is that we're now hardcoding workarounds for 2/40 of the setters that FormState provides. Imagine 38 more of these issues, across 4-6 modules...
Why not instead spend the time to fix it once?

claudiu.cristea’s picture

claudiu.cristea’s picture

Status: Reviewed & tested by the community » Closed (duplicate)