I've assigned some value with HTML tags to a form element, say the element is called name.

When it returns the form, it exactly prints the value along with the HTML. What I want in return instead, is the style applied to the text.

In this what I'm trying to do is hook_form_FORMID_alter(). This is the page where comments are listed(admin/content/comment). In this, for each comment I'm showing the subject comment and author etc. Also a collapsible tree for editing the comment with pre filled values in the fields.

$form['name'] = '<b>Fazeela</b>'
return $form;
  • What type of element is $form['name']? Are you talking about text that is in a text field or text area? – rooby May 12 '15 at 5:21
  • 1
    when referencing code, please post the code here, not a link to the code - if the link dies, the question will be useless for future people viewing it – Geoff May 12 '15 at 5:40
  • It is not a field, there is a collapsible tree, in which I am printing this value. – Fazeela Abu Zohra May 12 '15 at 5:46
  • May you provide the full code of that function, and explain exactly what is wrong in the result you are obtaining? – kiamlaluno May 12 '15 at 9:00
  • @kiamlaluno Hi, I have edited the code and requirement. Please let me know if you need further clarification. – Fazeela Abu Zohra May 12 '15 at 9:25

Use css.


If your $form['name'] is a div with an id wrapper,

<div id="wrapper">Fazeela</div>

Include a css file in your module file, particularly in hook_init function.

function NameOfYourModule_init(){
   drupal_add_css(drupal_get_path("module", "NameOfYourModule") . "/mycss.css"); 

mycss.css file

    font-weight: bold;
  • Did you see the code? – kiamlaluno May 12 '15 at 5:45
  • Is this the best way to do this? – Fazeela Abu Zohra May 12 '15 at 5:48
  • @FazeelaAbuZohra There is no need to include a CSS style file for rendering something in bold. See my answer. – kiamlaluno May 12 '15 at 5:50

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.