1

I have form built with form api in Drupal 8, now, i want to show an image and some text description on top of that form, meaning, before the form is rendered, what i can think of is, doing a node_load and then suffix and prefix with the node_load value or entity load, but my question is, in case i write a function for node_load or entity_load, where would i call the return value of these functions and how ? i am thinking of something like this :

$form['image_div'] = array(
            '#prefix' => '<div class="image"><img src="path_to_image" />',
            '#suffix' => '</div>',
        );

how can i call the path to image here, which is a function return value.

1 Answer 1

3

Example:

 $theme = \Drupal::theme()->getActiveTheme();    
 $form['image_div'] = array(
 '#prefix' => '<img src="/' . $theme->getPath() .'/images/smile.png">',
        '#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.