0

I'm using Drupal 7.

I have a template preprocess function overridden in my template.php as

It does not alter the output as desired.

When I comment out (or delete) the original preprocessor (template_preprocess_views_exposed_form(&$vars)) in the contrib module's theme.inc, the overridden preprocess function then takes effect as it should.

What do I have to do to get my preprocess to work without having to hack a contributed module?

Here is the offending code:

function ncmr_preprocess_views_exposed_form(&$vars){
  $form = $vars['form'];

  if ($form['ncmr_days_only']) {
    $form['ncmr_days_only']['value']['day']['#options'] = array(
      '' => 'Select Day',
      '5' => 'April 5',
      '6' => 'April 6',
      '7' => 'April 7',
    );

    $form['ncmr_days_only']['value']['day']['#printed'] = FALSE;
    $form['ncmr_days_only']['value']['month']['#value'] = 4;
    $form['ncmr_days_only']['value']['month']['#printed'] = FALSE;
    $form['ncmr_days_only']['value']['year']['#value'] = 2013;
    $form['ncmr_days_only']['value']['year']['#printed'] = FALSE;

    $vars['widgets_ncmr']['filter-field_session_date_value']->widget = drupal_render($form['ncmr_days_only']['value']);
  }
}
  • 1
    Please show us your code? – Alex Gill Jan 24 '13 at 13:40
  • have you tried using mythemename_preprocess_views_exposed_form(&$vars) – Mohammed Shameem Jan 24 '13 at 13:56
  • Yes I am, see above. – hdy Jan 24 '13 at 14:33
  • This just seems very wrong. It's a theme function for all filter forms but your using it for a specific form. – Alex Gill Jan 24 '13 at 14:38
  • If your going to do this you should probably try and incorporate your code with the existing code i.e. copy all the code from core then add yours to it on your theme override. – Alex Gill Jan 24 '13 at 14:43
1

Try the following...

function THEME_preprocess_views_exposed_form(&$vars, $hook)
{
        if ($vars['form']['#id'] == 'FORM_ID')
        {
              // blah blah
        }
}

This way you shouldnt override the core stuff, thus not affecting your code either.

| improve this answer | |

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.