Buy Now
Sign in

No name attribute on submit button prevent detection of firing button

Collie-IT , May 11 2021, 13:16
Collie-IT 96
May 11 2021, 13:16 #396417
[div wfd-id="156"]Dear Support,[/div][div wfd-id="155"]​[/div][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][div wfd-id="166"]​[/div][div wfd-id="169"]According to this post this seems to be a bug.[/div]
Best regards
Collie-IT 96
May 11 2021, 13:18 #396418
I found out how to set the Name-Attribut. Feel free do adujust my
solution. I Added the name attribute generation under

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
  • , ['button'])){
    if(isset($node['content']) && is_array($node['content']) && sizeof($node['content']) >0 && !isset($node['attrs']['name'])){
  • ="name='".$node['attrs'
  • ['id']."'";
  • ="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 96
    May 12 2021, 07:40 #396426
    A nother way to deal with the issue is to add the name and ID attibute to every button via HTML-Attributues.
    stwgroup 19
    June 12 2021, 14:04 #396662
    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.