Hi,

I am trying to change the action of a form, with no success... the code I have right now is:

if ($vars['form']['#id'] == 'views-exposed-form-Soka-page-4') {

$vars['form']['#action'] = "/search";

// Rebuild the rendered version

unset($vars['form']['#action']);
$vars['form'] = drupal_render($vars['form']);

}

The function is placed in template.php

Comments

MiSc’s picture

I was targeting the wrong variable I think - with $form['#action'] it worked a lot better...

Anyhow, I moved the function to an own module instead of using template.php, and now it works great, the function in the module looks like this:

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

switch ($form['#id']) {

//the id of the form works as case

case 'views-exposed-form-Soka-page-1':
$form['#action'] = '/sok';
break;

case 'views-exposed-form-Soka-page-2':
$form['#action'] = '/sok';
break;

case 'views-exposed-form-Soka-page-3':
$form['#action'] = '/sok';
break;

case 'views-exposed-form-Soka-page-4':
$form['#action'] = '/sok';
break;

case 'views-exposed-form-Soka-page-5':
$form['#action'] = '/sok';
break;

case 'views-exposed-form-Soka-page-6':
$form['#action'] = '/sok';
break;

case 'views-exposed-form-Soka-page-7':
$form['#action'] = '/sok';
break;
}

}

// Mikke Schirén @ http://wunderkraut.com/