1

I have a content type with a date field. I further have a view with an exposed filter for this date field.

In the view I don't want to filter for a specific date range but for any or no value set.

In Views in the settings for exposed filters on date fields I couldn't find an option to simply filter for whether this field has been filled in or not.

I suppose I need to alter the form and query, so that I can filter the view result for nodes where this date field has been set, respectively left empty.

I already managed to alter the form but I have no idea how to alter the actual query to make this form do what it is supposed to.

This is what I have so far:

if ($form_id == 'views_exposed_form' && $form_state['view']->name == 'my_view' && 
    $form_state['view']->current_display == 'page_3') {

    $form['field_my_date'] = array(
      '#type' => 'select',
      '#options' => array(0 => t('- Any -'), 1 => 'No', 2 => 'Yes'),
      '#default_value' => 0,
      '#title' => t('date is set'),
    );
}

I am really thankful for every hint on how to accomplish this.

  • can you explain your requirement little bit more..?? – Abin Aug 21 '15 at 7:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.