1

Is it possible to add more values into the #markup of a drupal form?

At the moment it is a link but I also want to add an image. When I add another #markup it only takes the last one, and when I add $image to the other #markup it doesn't work.

My code:

$image_options = array(
    'path' => 'img_url',
    'alt' => 'App logo',
    'title' => 'App logo',
    'width' => '56px',
    'height' => '56px',
    'attributes' => array('class' => 'some-img', 'id' => 'my-img'),
);

$image = theme('image', $image_options);

$form["link$key"] = array(
  '#type' => 'item',
  '#description' => t('Registered token(s): @total_tokens <br> Total sent push notifications: @push_notifications', array('@appname' => $record->app_name, '@total_tokens' => $total_tokens, '@push_notifications' => $sentMessages)),
  // '#href' => "admin/config/services/push_notifications/stats/". $record->app_id,
  '#markup' => l($record->app_name, 'admin/config/services/push_notifications/stats/' . $record->app_id),
);

So I want to be able to add $image to the current #markup..

4

The #markup property simply provides a string output.

Why dont you just concatenate your output into a variable.

$output = $image;
$output .= $link;

Then...

'#markup' => $output

Checkout the coding standards for Drupal around concatenation. https://www.drupal.org/coding-standards#concat

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.