-1

In the field.tpl.php the following code:

<div class="<?php print $classes; ?>"<?php print $attributes; ?>>
  <?php if (!$label_hidden): ?>
    <div class="field-label"<?php print $title_attributes; ?>><?php print $label ?>:&nbsp;</div>
  <?php endif; ?>

The code is printing the label of the field. I want to set, conditionally, $label_hidden = false from more general place other than the field.tpl.php itself.

I tried the following snippet from template.php:

function my_foundation_preprocess_field(&$variables){
  print_r($variables);
}

To get the value I mean but all I found is [#label_display] => hidden as an array element. In addition, the form I meant with is not found in that array, the search form.

So I need a way to set $label_hidden = true to prevent the Search label of the search text box.

1 Answer 1

0

Forms are handled differently than the variables, like node content, etc. You can find information on customising the Search form here. A common method for hiding the label is to use CSS and simply make it display:none. It's exact nomenclature will depend on how exactly you have implemented the search form.

4
  • Unfortunately, the link you regarded about _form_alter(), it does not solve my issue. It has no any access to the label tag before the search input text in the search form. However, partially, it could be solved by defining the css class .element-invisible in my theme css and set its display to be none.
    – SaidbakR
    Commented Jun 29, 2014 at 15:15
  • can you post a screenshot of what "label" you are referring to and want to remove?
    – Geoff
    Commented Jun 29, 2014 at 17:16
  • the screen shot at the following link: tinypic.com/r/nzhc2e/8
    – SaidbakR
    Commented Jun 29, 2014 at 19:03
  • it kind of looks like a block title perhaps? go to admin/structure/block and find the search block for the appropriate theme. click on configure, and see if the block has that title. To show no title, type <none> in the title
    – Geoff
    Commented Jun 29, 2014 at 19:23

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.