Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-2.10
Component:
exposed filters
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
7 May 2010 at 21:59 UTC
Updated:
22 May 2010 at 00:00 UTC
I have implemented the code in my module -custommodule.module
function custommodule_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'views_exposed_form') {
$form[tid]['#default_value'] = intval('46');
dsm($form);
}
}
And after checking on dsm, I can see that my value has been passed, But the filter itself doesn't seem to be affected.
(I used intval because without my code there was an integer value, I also tried without it)
What am I missing ?
Regards,
ohad
Comments
Comment #1
ohadsh535 commentedOK.. I finally got it.
I needed to change the $form_state
The correct code was: (while $mytid is being declared as needed)
Glad I didn't waste anyone's time
Comment #2
ohadsh535 commentedIt feels like my solution is kind of crooked..
It takes too much PHP actions for that simple modification
If anyone can review my code and offer an alternate solution it'll be great
Comment #3
merlinofchaos commentedYour solution is mostly correct, because Forms API has some strange issues with GET forms because of some assumptions that are made if values are not filled in. Setting the input is good; however, you should *only* set the input if the corresponding exposed input ($view->exposed_input I believe) is not set.