No name attribute on submit button prevent detection of firing button

Collie-IT 11 May, 2021
[div wfd-id="156"]Dear Support,[div wfd-id="155"]​[div wfd-id="167"]the Buttons in Chronoforms7 don't get the name-attribute anymore. If you have 2 or more buttons. There is no direct method to detect which button has fired the submit.[div wfd-id="166"]​[div wfd-id="169"]According to this post this seems to be a bug.

Best regards
Collie-IT
Collie-IT 11 May, 2021
Answer
I found out how to set the Name-Attribut. Feel free do adujust my
solution. I Added the name attribute generation under

wp-content\plugins\chronoforms\chronog3\helpers\html.php

Line 98

Edit to make the code better I have added a exlusion if Name or ID is set
 //Button Needs Name for getting submitted right. Collie-IT, Anne K. Frey 12.05.2021
if(in_array($node['tag'], ['button'])){
if(isset($node['content']) && is_array($node['content']) && sizeof($node['content']) >0 && !isset($node['attrs']['name'])){
if(isset($node['attrs']['id'])){
$out[] ="name='".$node['attrs']['id']."'";
}else{
$out[] ="name='".$node['content'][0]."'";
}
}
}

//Missing ButtonIDs
//Button Needs Name for getting submitted right. Collie-IT, Anne K. Frey 12.05.2021
if(in_array($node['tag'], ['button'])){
if(isset($node['content']) && is_array($node['content']) && sizeof($node['content']) >0 && !isset($node['attrs']['id'])){
$out[] ="id='".$node['content'][0]."'";
}
}
Collie-IT 12 May, 2021
1 Likes
A nother way to deal with the issue is to add the name and ID attibute to every button via HTML-Attributues.
stwgroup 12 Jun, 2021
1 Likes
To add one comment on this.
If you have multiple submit buttons add 2 HTML attributes, NAME and VALUE.
Give all the submit buttons the same and a unique value.
In the action section of the submission page, The name value will be sent with the form and you can check for the value and code accordingly.
You need to login to be able to post a reply.