2

How can I add an inline style to an addressfield field without having to modify the template files?

I'm using the addressfield as a field in my user object and am trying to load the full user object in the commerce order display page.

This page is being rendered using the admin theme which is the default Seven theme. I'm trying to avoid having to modify that default theme for this purpose.

Here's the relevant code:

function MYMODULE_entity_view($entity, $type, $view_mode, $langcode){
  if ($type == 'commerce_order') {
    $uid = $entity->uid;
    $user = user_load($uid);
    $renderable_user = user_view($user, 'default');  //<-- Can I modify this array to add an inline style?
    $entity->content['customer_info'] = array(
      '#weight' => -2,
      '#markup' => render($renderable_user),
      );
    }
}

Or perhaps I'm going about this the wrong way and there's another way to modify the output of this page?

2

Check out the CSS Injector module. It won't do inline styles, but you could always write a selector (which is the best practice anyway).

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.