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
I am building a form which requires access to some of the submission values on a custom confirmation page. It would be great to replace tokens in the confirmation_url, so that I can load the form and pull data out of it.
Proposed resolution
Replace tokens on any settings where it seems appropriate to do so.
Remaining tasks
Patch.
User interface changes
Perhaps the addition of some text describing the behavior?
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#22 | yamlform.yamlform.test_token_redirect.yml | 1.72 KB | jrockowitz |
#21 | replace_yamlform-2773827-21.patch | 14.85 KB | jrockowitz |
#12 | replace_yamlform-2773827-12.patch | 804 bytes | jrockowitz |
#3 | replace_yamlform-2773827-3.patch | 1.15 KB | jrockowitz |
#2 | 27738270-replace-tokens-2.patch | 910 bytes | Sam152 |
Comments
Comment #2
Sam152 CreditAttribution: Sam152 at PreviousNext commentedQuick and dirty patch for my purposes. I think the final solution would perhaps work on more settings, be better tested etc.
Comment #3
jrockowitz CreditAttribution: jrockowitz as a volunteer commentedAttached is less 'dirty' patch, that might be okay without any tests. If it works, I can probably just commit it.
Comment #4
Sam152 CreditAttribution: Sam152 at PreviousNext commentedLooks good to me.
Comment #6
jrockowitz CreditAttribution: jrockowitz as a volunteer commentedDone!
Comment #7
jrockowitz CreditAttribution: jrockowitz as a volunteer commentedComment #8
Stephen OllmanShould this work on the settings page from the confirmation URL field?
/node/[yamlform-submission:values:my_field_name:value]
Where 'my_field_name' is simply a node ID that called the form via a modal.
Right now I just getting the 'node' page returned, thus the token is being ignored.
Am I right in saying that I can use submission value tokens on the settings page?
Oh and thanks for this module!
Comment #9
Stephen OllmanFURTHER TO THIS
I've just noticed that the token works when running it through a test cycle. Configuration URL works a treat, just not when doing it live.
UPDATE
Scrap that whilst the test cycle is redirecting to a node page its totally a random node.
Basically the token is not returning the correct value of the field during a test and totally ignored during a live run.
However I can use the token in the confirmation message, just not the URL.
Comment #10
jrockowitz CreditAttribution: jrockowitz as a volunteer commentedComment #11
jrockowitz CreditAttribution: jrockowitz as a volunteer commentedI think
\Drupal\field_ui\Form\EntityDisplayFormBase::copyFormValuesToEntity
needs to be called before the tokens are replaced. I just need to determine where this call should be made in\Drupal\yamlform\YamlFormSubmissionForm
.Comment #12
jrockowitz CreditAttribution: jrockowitz as a volunteer commentedLet's see if the attached patch passes.
Comment #14
jrockowitz CreditAttribution: jrockowitz as a volunteer commentedOkay, this is going to be much harder than it seems because the setting tokens need to be replaced after the form_state has been populated.
I think all calls to retrieve a YAML Form setting will have to pass thru \Drupal\yamlform\YamlFormSubmissionForm::getYamlFormSetting() which can do lazy token replacement.
Comment #15
Stephen Ollmanerror after applying patch:
Fatal error: Call to a member function extractFormValues() on null in /docroot/core/lib/Drupal/Core/Entity/ContentEntityForm.php on line 223
Comment #16
jrockowitz CreditAttribution: jrockowitz as a volunteer commented@Stephen Ollman. Thanks reviewing the patch. I am on vacation until 8/1 and fixing this issue is going to require some serious concentration.
Comment #17
Stephen OllmanI really appreciate your help and look forward to hopefully seeing a working patch soon. I feel this module will be a big asset to D8.
Enjoy your break!
Comment #21
jrockowitz CreditAttribution: jrockowitz as a volunteer commentedMy issue queue is filling up.... got a quiet moment to focus on making the needed tweak.
Comment #22
jrockowitz CreditAttribution: jrockowitz as a volunteer commentedAttached is the form I used to test that submitted values are being used by the confirmation URL.
Comment #24
jrockowitz CreditAttribution: jrockowitz as a volunteer commentedComment #25
robpowell@jrockowitz - the 21 patch didn't work for me locally I got the following error:
patch -p1 --dry-run < replace_yamlform-2773827-21.patch
patching file src/YamlFormSubmissionForm.php
Hunk #1 succeeded at 175 (offset -2 lines).
Hunk #2 succeeded at 210 (offset -2 lines).
Hunk #3 succeeded at 223 (offset -2 lines).
Hunk #4 succeeded at 270 (offset -2 lines).
Hunk #5 succeeded at 280 (offset -2 lines).
Hunk #6 succeeded at 312 (offset -2 lines).
Hunk #7 succeeded at 411 (offset -2 lines).
Hunk #8 succeeded at 421 (offset -2 lines).
Hunk #9 succeeded at 445 (offset -2 lines).
Hunk #10 succeeded at 460 (offset -2 lines).
Hunk #11 succeeded at 479 (offset -2 lines).
Hunk #12 succeeded at 577 (offset -2 lines).
Hunk #13 succeeded at 598 (offset -2 lines).
Hunk #14 succeeded at 621 (offset -2 lines).
Hunk #15 FAILED at 630.
Hunk #16 FAILED at 640.
Hunk #17 succeeded at 889 (offset -14 lines).
Hunk #18 succeeded at 929 (offset -14 lines).
Hunk #19 succeeded at 956 (offset -14 lines).
Hunk #20 succeeded at 963 (offset -14 lines).
Hunk #21 succeeded at 987 (offset -14 lines).
Hunk #22 succeeded at 997 (offset -14 lines).
Hunk #23 succeeded at 1007 (offset -14 lines).
Hunk #24 succeeded at 1110 (offset -14 lines).
Hunk #25 succeeded at 1131 (offset -14 lines).
2 out of 25 hunks FAILED -- saving rejects to file src/YamlFormSubmissionForm.php.rej
also, I tried testing via the simplytest.me link and that error'd and didn't set up the instance.
Comment #26
Stephen OllmanSame failure here when applying the patch. Also a number of visual form elements seem to be adversely effected by the patch. ie the submit button.
Comment #27
jrockowitz CreditAttribution: jrockowitz as a volunteer commented@Stephen Ollman @robpowell I applied the patch to 8.x-1.x so you just need to download the 8.x-1.x-dev release.
Because this module is still in beta and I am trying to get as much done as possible before DrupalCon Dublin, occasionally I will just apply a patch. especially if it passes all the tests and I am comfortable that the issue and solution won't break anything.
Moving forward besides marking the issue as fixed. I will add a comment stating that I applied the patch to 8.x-1.x.
BTW, thanks for taking the time out to review the patches.
Comment #28
Stephen OllmanBOOM!
Works like a charm. After enabling 8.x-1.x and applying the patch #21, the confirmation URL token works perfectly.
Great job jrockowitz.
Comment #29
Stephen OllmanOn a quick side note: is it possible to send email using the username rather than the email address?
Comment #30
jrockowitz CreditAttribution: jrockowitz as a volunteer commented@Stephen Ollman. I don't understand your request. Do you want just the username displayed as the sender in the email clients?
Feel free to open a new ticket
Comment #31
Stephen OllmanIf I have a form field that captures the username, can that field be used as the 'To' address component in the email config?
Comment #32
jrockowitz CreditAttribution: jrockowitz as a volunteer commentedThis feature is currently not supported by the YAML Form module. I am not sure why but I don't see other form builder's supporting this feature/behavior.
Please open a new ticket.