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.
Problem/Motivation
The Webform image select element should support reusable images. The Webform options config entity only supports name/value pairs for select menu, checkboxes, and radio buttons.
Proposed resolution
Create a Webform Image Select Image module with a dedicated config entity to manage reusable images.
Notes
- The image select element will moved into a dedicate sub-module called 'Webform image select' (webform_image_select.module)
Remaining tasks
Create webform_image_select.moduleMove \Drupal\webform\Element\WebformImageSelectMove \Drupal\webform\Plugin\WebformElement\WebformImageSelectMove \Drupal\webform\Tests\Element\WebformElementImageSelectTestMove webform.webform.test_element_image_select.ymlCreate WebformImageSelectImages config entity with schemaCreate WebformImageSelectImages managerCreate WebformImageSelectImages select element.Update WebformImageSelectAdd alter hook to Webform librariesAllow external libraries to be requiredWrite alter hooksUpdate examples.Create webform_image_select_test.moduleWrite update hook to enable the webform_image_select.module if it is being used by any existing webformWrite testsCode reviewWrite test scriptWrite change record
Publish change record
User interface changes
- Adding 'Images' tab to 'Configuration' (/admin/structure/webform/config/options/images)
- Update image select element ui.
API changes
Webform libraries manager will allow other modules to declare external libraries
Data model changes
None
Test Script
Test configuration import via install
- Enable webform_image_select module or run update hooks (/admin/modules)
- Confirm that kitten images are imported (/admin/structure/webform/config/images/manage)
Test IMCE integration
- Download IMCE
- Enable IMCE (/admin/modules)
- Confirm browse link is added below images src (/admin/structure/webform/config/images/manage/bears/edit)
Test CRUD operations
- Create test images (/admin/structure/webform/config/images/manage/add)
- Update test images (/admin/structure/webform/config/images/manage/test/edit)
- Edit source new images (/admin/structure/webform/config/images/manage/test/source)
- Duplicate new images (/admin/structure/webform/config/images/test/duplicate)
- Delete new images (/admin/structure/webform/config/images/test/delete)
Test image select element with custom images
- Add image select to Contact form (/admin/structure/webform/manage/contact)
- Enter custom images and save (/admin/structure/webform/manage/contact/element/add/webform_image_select)
- Confirm image select element (/form/contact)
Test image select element with reusable image
- Add images select to Contact form (/admin/structure/webform/manage/contact)
- Select reusable kittens and save (/admin/structure/webform/manage/contact/element/add/webform_image_select)
- Confirm image select element (/form/contact)
Test image select preview and rendering
- Generate test submission (/webform/contact/test)
- Confirm results table show thumbnails (/admin/structure/webform/manage/contact/results/submissions)
- Confirm submission HTML view (admin/structure/webform/manage/contact/submission/SID)
- Confirm submission Plain text view (admin/structure/webform/manage/contact/submission/SID/text)
Comment | File | Size | Author |
---|---|---|---|
#36 | 2933909-36.patch | 99.07 KB | jrockowitz |
| |||
#33 | 2933909-32.patch | 99.13 KB | jrockowitz |
| |||
#31 | 2933909-30.patch | 105.13 KB | jrockowitz |
#28 | 2933909-28.patch | 0 bytes | jrockowitz |
#25 | 2933909-25.patch | 96.17 KB | jrockowitz |
|
Comments
Comment #2
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #3
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #8
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedPatch is making sure that nothing is breaking.
Comment #12
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #15
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #16
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #19
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #22
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #25
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #26
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House for Rosewood Marketing commentedComment #28
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House for Rosewood Marketing commentedComment #29
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House for Rosewood Marketing commented@Adrian83 Please review the patch or checkout the dedicated GIT branch.
Comment #31
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House for Rosewood Marketing commentedComment #33
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House for Rosewood Marketing commentedOuch! I rebased the branch and this patch should be okay.
Comment #34
Adrian83 CreditAttribution: Adrian83 commentedI'll try to take a look at the patch this afternoon.
Comment #35
Adrian83 CreditAttribution: Adrian83 commentedI installed the patch via composer against dev successfully. But in order to apply the patch I needed to change version from rc3 to dev. That was successful, but when I try to run drush updb, I get the following error:
Comment #36
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House for Rosewood Marketing commentedAttached is a re-rolled patch.
Comment #37
Adrian83 CreditAttribution: Adrian83 commentedI was able to install the patch without problems. Everything works as I would have expected it to. I added two image select optionsets and added them to two different forms. Then I removed an image from the optionset and verified that the image was removed from both forms. I added the image back in and verified that the image reappeared in both forms.
So far, I'm not seeing anything missing.
Comment #39
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House for Rosewood Marketing commentedI committed the patch. Thanks
Comment #40
Adrian83 CreditAttribution: Adrian83 commentedThank you.
Comment #42
simoncritchell CreditAttribution: simoncritchell commentedHello Jacob,
I am trying to get this module to allow me choose an image in select option.. i have 3 options: (new is red) colour or png img, in progress is yellow, and green is done.. should i be using CSS to view the selectd option in webform results ( a css colour per selected option?) or should i be using this module?
using D7 and all modules are Up to date..
this is the value i get in my webform edit field : a:1:{i:0;s:0:"";}
should i be using a special img folder? is there some img forlder settings to get set? i semms i can't save imgs in my select img widget.
thanks
cheers simon*
Comment #43
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House for Rosewood Marketing commentedThis functionality is only available for D8. For D7, try using https://www.drupal.org/project/webform_select_image
Comment #44
simoncritchell CreditAttribution: simoncritchell commentedThank you Jacob, i am using D7 and https://www.drupal.org/project/webform_select_image
Somehow it doesn't manage to store the uploaded images in :
label- form key- type- value-
img | img | Select image | a:1:{i:0;s:0:"";} | Modify Clone Cancel
Should i maybe: fixe some permissions? or set some special folder for loading img?
Comment #45
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House for Rosewood Marketing commented@simoncritchell You need to post your question to https://www.drupal.org/project/issues/webform_select_image?categories=All
Comment #46
simoncritchell CreditAttribution: simoncritchell commentedHello Jacob,
Could we alter row background colour based on select option? it allow a user to put a webform submission into a prefered state ( new request ) and the row background colour would set to red for example?
any ideas?
Comment #47
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House for Rosewood Marketing commentedAltering the background colors would have to be done using CSS.
Comment #48
coxy0001 CreditAttribution: coxy0001 commentedHaving issues with this - the images don't always render. See source code below from inspect:
When it doesn't render the images:
When it does render the images:
It doesn't always render the code properly - why is this?
EDIT: To give a bit more context.... I have wizard page selected that contains this image select. When I load the webform this image select is in page 1 and the images don't appear. When I fill in the page 1 form fields, go to page 2 and then click "page 1" in the wizard toolbar the image select images then display.
Comment #49
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House for Rosewood Marketing commentedIf the image select fails to render it most likely due to an unrelated JavaScript error which stops the image select JavaScript from completing. You should check what is being logged in the browser's JavaScript console.