Problem/Motivation
The block add route can be accessed without the theme parameter. The theme select will appear at that point. Whenever the theme is changed, an AJAX callback will update the available regions. If a region is picked and then the theme is changed, a validation error will appear if the previously selected region doesn't exists for the new theme.
This is caused by the region list being updated inside the AJAX callback. This also causes the to lose the empty option added in the select element process.
Furthermore, due to this approach, the region list is not alterable during hook_form_alter() implementations.
For example, the block_region_permissions module cannot access the rebuilt list.
Steps to reproduce
How to reproduce the validation error:
- Login as a user with the administer blocks permission and visit
admin/structure/block/add/system_powered_by_block(any other block will be fine); - Select the Seven theme, then select the "Pre-content" region;
- Select back the Bartik theme. The error will be shown. Also notice the missing empty option.
Proposed resolution
Build the correct region list in the form, and just return the form element in the AJAX callback.
Remaining tasks
Finalise the test coverage.
User interface changes
None.
API changes
None.
Data model changes
None.
Release notes snippet
TBD.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | 3173159-7.patch | 2.85 KB | jeroent |
Comments
Comment #2
sardara commentedUploading a test and the fix. The test is just a start, I think we should add also the check that the options are the expected ones.
Comment #4
sardara commentedThe coding standard fix.
Comment #7
jeroentTests were no longer running because of some coding standard issues.
Comment #8
jeroentCode looks good to me, the code fixes this issue and has test coverage. So updating the status to RTBC.
Let's see if the testbot agrees.
Comment #9
alexpottCommitted and pushed 8ecb3da5dd to 10.0.x and 70d94d4972 to 9.4.x and 19c559c8d5 to 9.3.x. Thanks!