0

I try to customize fieldset ABC that are inside drupal commerce checkout page. Markup looks like this

<fieldset>
 <legend>ABC</legend>
 <div class="fieldset-wrapper">
  <div class="form-item"></div>
  <div class="form-item"></div>
 </div>
</fieldset>

I would like to put some additional code directly inside fieldset and then also some other html directly inside form-item elements. Question> What should I do to achieve that? I found this page https://api.drupal.org/api/drupal/includes!form.inc/function/theme_fieldset/7 would it be of any help? Thank you.

images enter image description hereenter image description here

2

Try to change it using hook_form_FORM_ID_alter().

// Replace FORM_ID with commerce checkout form id
function hook_form_FORM_ID_alter($form, &$form_state, $form_id) {
  $form['fieldset_item']['mymarkup'] = array(
    '#type' => 'item',
    '#markup' => 'My Markup Here.',
  );
}
| improve this answer | |
  • HI, this has no effect on my form. Where should be the markup visible? I try to dmp the form but I can not see 'markup' – loparr Dec 3 '14 at 14:00
  • mymarkup is the new element which you will be insert and you have to set #weight for adding it in middle of the form otherwise it will appear last. – Sumit Madan Dec 3 '14 at 14:02
  • Hi,if I put your code inside custommodule and replace hook_form... with test_form_commerce_checkout_form_checkout_alter (test is name of my module), then all fieldsets should have 'My Markup Here.' somewhere in their markup right? But they dont, even after flushing cache. And dmp($form) does not show any 'fieldset_item' element, only #type fieldset. What I am missing here? Thank you. – loparr Dec 3 '14 at 14:19
  • fieldset_item is the key for fieldset element. It will add the item in existing fieldset. – Sumit Madan Dec 3 '14 at 14:22
  • Thank you for explanation, however as I said I can not see any changes. – loparr Dec 3 '14 at 14:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.