How to remove square brackets from name attribute in webform elements? Name attribute in rendered webform elements contain square brackets like submitted[field_machine_name].



.



Is there a way to replace square brackets in the name, so the name attribute looks something like "field_machine_name", without breaking the webform submission handler?
you can use hook_form_alter

Example D8

function hook_form_alter(&amp;$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {

  if ($form_id=='comment_comment_form') {

    $form['subject']['widget']['0']['value']['#name'] = 'field_machine_name';

  }

}


Example D7

function comment_form_alter(&amp;$form, $form_state, $form_id) {

 if ($form_id=='comment_node_article_form')        {
    $form['subject']['#name'] = 'field_machine_name';
 }

}