In my Drupal 7 commerce website, I have my checkout page which will add my billing and shipping profiles. I need to just display my shipping address and billing address, instead of input fields. (Data fed from an ERP backend.)

So I've hidden al the input fields. Now I want to render the addresfield value and add it to my form just for display. But I seem to be unable to do so.

I have the following code in my form alter:

  $handlers = array('address' => 'address');
  $context = array('mode' => 'render');
  $address_render_array = addressfield_generate($form['customer_profile_shipping']['customer_profile']['#value']->commerce_customer_address, 
                            $handlers, $context);
  dpm($address_render_array, 'render arr');
  dpm(drupal_render($address_render_array), 'rendered');

However drupal_render() returns an empty string and I do not understand why. I've tried to X-debug, and I saw strangely enough that #access vars where FALSE, but I'm not finding out why.

After which I want to display it in my form

Something like

$form['my-address'] = array('#markup' => $renderedaddress);

1 Answer 1


I used

  $output = field_view_field('commerce_customer_profile', $form['customer_profile_shipping']['customer_profile']['#value'], 'commerce_customer_address');
  $form['customer_profile_shipping']['rendered_address'] = array(
    '#prefix' => '<div class="checkout-address">',
    '#markup' => render($output),
    '#suffix' => '</div>'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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