2

I have a view that pulls in content of many different types. I gave the user two exposed filters, using the Better Exposed Filters module. However, the two filters look different. I would like them to look the same.

enter image description here

Specifically, I would like to get rid of the "Start date", "End date", and "E.g., 2017-02-01" labels on the filter on the right hand side.

How do I do this? Is it possible to do it within the view settings? If not, I don't mind writing a custom solution. I imagine there's a relevant hook somewhere, but I do not know which one to use.

2
  • 1
    have you tried editing the 'label' in the view field?
    – danuddara
    Commented Feb 1, 2017 at 22:41
  • The setting I'm looking for isn't there :-( Commented Feb 2, 2017 at 21:29

1 Answer 1

2

Turns out these settings can't be changed in the View (that I was able to find, and I looked pretty extensively). But, with Drupal's module/hook system, it's a pretty quick fix.

Source: How to remove format description in date_popup form field?

First, get rid of Start date and replace End date with And to match the filter on the left:

function edit_date_form_form_alter(&$form, &$form_state, $form_id) {
  if ($form['#id'] === "views-exposed-form-editable-content-page") {
    $form["field_editor_review_date_value_1"]["min"]["#title"] = "";
    $form["field_editor_review_date_value_1"]["max"]["#title"] = "And";
  }
}

Then, get rid of the E.g., 2017-02-01:

function edit_date_form_date_popup_process_alter(&$element, &$form_state, $context) {
  $element['date']['#description'] = "";
  $element['time']['#description'] = "";
}

Plop those into a module, enable it, and your output is:

enter image description here

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.