Ok, I finally found a solution, but if someone has a better one, please let me know.
I found that I wasn't able to modify the name attribute from the hook form alter, so I went higher up. I first tried altering the button with a preprocess function, which didn't work. I was only able to do it by overriding the actual theme_button. Code below (note: I'm using a bootstrap subtheme):
/**
* Overrides theme_button().
*/
function mytheme_button($variables) {
$element = $variables['element'];
$label = $element['#value'];
element_set_attributes($element, array('id', 'name', 'value', 'type'));
// If a button type class isn't present then add in default.
$button_classes = array(
'btn-default',
'btn-primary',
'btn-success',
'btn-info',
'btn-warning',
'btn-danger',
'btn-link',
);
$class_intersection = array_intersect($button_classes, $element['#attributes']['class']);
if (empty($class_intersection)) {
$element['#attributes']['class'][] = 'btn-default';
}
// Add in the button type class.
$element['#attributes']['class'][] = 'form-' . $element['#button_type'];
if($element['#type'] === 'submit') {
unset($element['#attributes']['name']);
}
dpm($element);
// This line break adds inherent margin between multiple buttons.
return '<button' . drupal_attributes($element['#attributes']) . '>' . $label ."</button>\n";
}
function mytheme_preprocess_button($variables) {
if($variables['element']['#type'] === 'submit') {
unset($variables['element']['#name']);
}
dpm($variables);
}
I found that I was able to remove the name attribute with this code in the mytheme_button
unset($element['#attributes']['name']);
but from inside the mytheme_preprocess_button, I was able to remove the #name attribute from the array with this
unset($variables['element']['#name']);
but it didn't actually remove the name from the form. In the preprocess, 'name' is not a sub element under '#attributes'.
Does this make sense? I would think the most Drupal solution would be to use the preprocess, if I can.