My preprocess function:

<?php

function mytheme_preprocess_views_exposed_form(&$vars, $hook) {

  // if exposed form ID
  if ($vars['form']['#id'] == 'views-exposed-form-outlets-page-1') {
  
    // hide the distance filter
     $vars['form']['distance']['search_distance']['#type'] = 'hidden';
  
    // Rebuild the rendered version (rest remains unchanged)
    unset($vars['form']['distance']['search_distance']['#printed']);
 
     // Render the widget
    $vars['widgets']['filter-distance']->widget = drupal_render($vars['form']['distance']['search_distance']);      
  }
}
?>

Problem: 'distance' is a nested array and when I render the widget, the only form item rendered is 'search_distance'. I attempted to change the widget render to:

<?php

     // Render the widget
    $vars['widgets']['filter-distance']->widget = drupal_render($vars['form']['distance']['search_distance']);   

?>   

...but the widget renders NULL.

Any thoughts on how I can modify this nested variable, then rebuild the widget with the change and have all other variables remain unchanged?

Thanks!

Comments

kars-t’s picture

Status: Active » Fixed

Dear fellow Drupal enthusiasts,

this issue is now lasting for a very long time in the issue queue and was unfortunately never solved. As Drupal is a open source project everyone is helping on voluntary basis. So that this is was not solved is nothing personal and means no harm. But perhaps no one had time to deal with this issue, maybe it is too complex or did not pose the problem comprehensible.

But this issue is not the only one. There are thousands of issues on Drupal.org that have never been worked on or could not be processed. This means that we are building a wave that is unmanageable and just a problem for the Drupal project as a whole. Please help us keep the issue queue smaller and more manageable.

Please read again, "Making an issue report" and see if you can improve the issue. Test the problem with the current Core and modules. Maybe the problem doesn't exist anymore, is a duplicate or has even been solved within this issue but never closed.

Help can also be found for it on IRC and in the user groups.

In order this issue no longer remains, I put this issue to "fixed".

If there is new information, please re-open the issue.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

brex’s picture

you can change forms in mythene_form_alter instead of in mytheme_preprocess_views_exposed_form

function hook_form_alter(&$form, $form_state, $form_id) {

if($form['#id']=='views-exposed-form-name-page')
{
$form['field']['#type'] = 'hidden';

views_form_validate($form, $form_state);
drupal_process_form($form_id, $form, $form_state);
}
....

this runs for me!

brex’s picture

Issue summary: View changes

fixed comment