How can I change the label for a view to be a div instead? Here is my HTML, its the "Sort by" label I need to change.

<form class="ctools-auto-submit-full-form views-exposed-form-author-content-panel-pane-1 ctools-auto-submit-processed" action="/" method="get" id="views-exposed-form-author-content-panel-pane-1" accept-charset="UTF-8"><div>

<!-- THEME DEBUG -->
<!-- CALL: theme('views_exposed_form') -->
<!-- BEGIN OUTPUT from 'sites/all/modules/contrib/views/theme/views-exposed-form.tpl.php' -->
<div class="views-exposed-form">
  <div class="views-exposed-widgets clearfix">
          <div id="edit-sort-bef-combine-wrapper" class="views-exposed-widget views-widget-sort-sort_bef_combine">
                        <div class="views-widget">
                    <div class="form-item form-type-radios form-item-sort-bef-combine">
  <label for="edit-sort-bef-combine">Sort by </label>
 <div id="edit-sort-bef-combine" class="form-radios"><ul class="btn-group"><li class="btn-group__item"><a href="http://localhost.site.com/news/author?sort_bef_combine=created%20DESC" class="btn btn--sort btn--active">Date</a></li><li class="btn-group__item"><a href="http://localhost.site.com/news/author-dobie?sort_bef_combine=value%20DESC" class="btn btn--sort">Popular</a></li></ul><input type="hidden" name="sort_bef_combine" value="created DESC"></div>
                    <div class="views-exposed-widget views-submit-button">
      <button class="ctools-use-ajax ctools-auto-submit-click js-hide btn form-submit" id="edit-submit-author-content" name="" value="Apply">Apply</button>

<!-- END OUTPUT from 'sites/all/modules/contrib/views/theme/views-exposed-form.tpl.php' -->


The template responsible is views-exposed-form.tpl.php. Within the template the code below prints the form:

    <div class="views-widget findhere ">
      <?php print $widget->widget; ?>

I've done a dsm on the $widget but the array just contains the full HTML.

Ive looked at hook_form_alter and done a dsm on this but in the full form array I still cant see a way to change the form label to a different element.

2 Answers 2


Looks like you are using better exposed filter module, it has option to configure the sorting label

enter image description here

so instead of Sort By <div>Sort by</div> it will not replace the label but give you a nested div if that works for you.

  • I dont understand your answer. Yes I am using better exposed filters module. I already have the those options populated. This puts the text "Sort by" within a label element which is what I need to change.
    – Evanss
    Commented Sep 11, 2015 at 12:33
  • I meant simply replace the text Sort by, with <div>Sort By</div> this will not replace the <label> but will give you a nested <div> inside <label>, if it helps you.
    – arpitr
    Commented Sep 11, 2015 at 12:36
  • Ah im afraid not. I need to remove the label element completely.
    – Evanss
    Commented Sep 11, 2015 at 12:37

You can use Semantic Views

Description form This module page:

This Views plugin makes unformatted styles, field row styles and other output more readily configurable without needing to override template files. Instead of overriding row style templates for views where you want to specify different HTML elements (tags) and class attributes, you can specify these inside the Views UI and avoid overriding templates for each view.

Some of Semantics Views functionality can be done in Views, but Views is restricted to use only predefined HTML element and can only style each Field but not wrap rows with any HTML you like.

And Also you can override views-view-fields.tpl.php

  • Thanks for the link. However id rather not load a new module just to fix one thing.
    – Evanss
    Commented Sep 11, 2015 at 10:48
  • @jdln your welcome, I update my answer, you can also override views-view-fields.tpl.php
    – Yuseferi
    Commented Sep 11, 2015 at 10:52

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.