I am trying to alter a form field, specifically in Drupal commerce but when I use the hook form alter, it removes the field altogether and just adds my alteration. Even if I do not add a field alteration, just simply declaring the field will also remove the field.
How can I just alter a form field, without losing the rest of the field.
function custom_theme_form_commerce_checkout_form_alter(&$form, &$form_state, $form_id) {
if($form_id == 'commerce_checkout_form_checkout'){
$form['cart_contents'] = array(
'prefix' => 'my alteration'
);
}
}
I figured it out, I need to do it as an assignment vs altering the entire array.
$form['cart_contents']['#prefix'] = 'my alteration';