Currently in my module, I have the following code :

function mymodule_form_search_form_alter(&$form, $form_state) {
  if (isset($form['module']) && $form['module']['#value'] == 'node' && user_access('use advanced search')) {
    $form['advanced'] = array(
      '#collapsible' => TRUE,
      '#collapsed' => FALSE,
    );
    unset($form['advanced']['type']);
    $form['#validate'][] = 'node_search_validate';
    dsm($form);
  }
}

So, dsm($form) prints that form at the top of /search/node, but the 'advanced' array and sub-arrays don't render properly - i.e. they consist of the changes made in this module and nothing more - and have no effect on the form itself. I also have Devel printing the $page array, and comparing the two, it appears that I am trying to alter the correct form.

Anything I try to do to edit the advanced search form has no effect, no matter what. I've been able to render the form uncollapsed using js, but seeing as I'd like to do more with it and require a form_alter to do so, I need this to start working soon.

Comments

ankur’s picture

Category: bug » support
Status: Active » Fixed

By setting $form['advanced'] equal to a new array, you are wiping out the array that already exists there.

Instead of


$form['advanced'] = array(
      '#collapsible' => TRUE,
      '#collapsed' => FALSE,
    );

you want


$form['advanced']['#collapsible'] = TRUE;
$form['advanced']['#collapsed'] = FALSE;

Status: Fixed » Closed (fixed)

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

dianacastillo’s picture

Version: 7.12 » 6.26
Status: Closed (fixed) » Needs review

can you explain which module you put this in ?
do you put it in the core?
I need to know how to do it in V6

dianacastillo’s picture

I made a module which keeps advanced search uncollapsed, you can download it here http://drupal.org/node/715634#comment-6713270

Status: Needs review » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.