Hello!
i used this wonderfull module for to have 2 selectable lists in exposed filter views. one with country and other with the city...
So i need that the default value to be - Country - and - City - in each list and not - any -
But i don't find any way of do it.....
How can i do it?
Thanks!

CommentFileSizeAuthor
#2 image1.png2.92 KBrabeto
#2 image2.png3.62 KBrabeto

Comments

stborchert’s picture

Status: Active » Postponed (maintainer needs more info)

Couldn't you set the default value in the field configuration?
If you navigate to admin/structure/types/manage/{YOUR_CONTENT_TYPE}/fields/{YOUR_FIELD_NAME} and scroll down you should see a fieldset named "Default value" where you can preselect a value.

If this is not what you intended to do, please provided more details about it.

rabeto’s picture

StatusFileSize
new3.62 KB
new2.92 KB

Hello thanks for your reply.
I need it for a exposed filter with views.
I've got the image 1 but i need something as image 2
I try with a hook_form_alter code :

function any_exposed_form_alter(&$form, &$form_state, $form_id) {
     if($form['#id'] == 'views-exposed-form-my-country-page') {
       $form['edit-shs-term-node-tid-depth-mio-select-1']['#options']['All'] = t('Country'); // overrides <All> on the dropdown 
       $form['edit-shs-term-node-tid-depth-mio-select-2']['#options']['All'] = t('City'); // overrides <All> on the dropdown 
  }

but not work... :-(

stborchert’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

This won't work since the options for the visible dropdowns are inserted using javascript and not configurable in such a way.

b777’s picture

Version: 7.x-1.x-dev » 7.x-1.6

I was trying to do the same thing. I have a Location and then a Cabin that users can filter results. I wanted some more descriptive text to inform them about the avaialble views filter.

I had to edit the modules/shs/js/shs.js file to get it to work.

Around line 139 of shs.js, I added a few if statements to check the value of the first option returned, and based on that, changed the text to say what I wanted.

So instead of

options[options.length] = new Option(Drupal.t('- Any -'), 0);

i now have

			if (data.data[0].label == "Lake Travis") {
				options[options.length] = new Option(Drupal.t('- Select Location -'), 0);
			} else if (data.data[0].label == "Arrowhead" || data.data[0].label == "Blackfoot") {
				options[options.length] = new Option(Drupal.t('- Select Cabin -'), 0);
			} else {
				options[options.length] = new Option(Drupal.t('- Any -'), 0);
			}
rabeto’s picture

Hello, i got to try it thanks!

rabeto’s picture

Issue summary: View changes

Better explanation

cirrus3d’s picture

Issue summary: View changes

I can confirm #4 works. Thanks b777.

The only problem is that if the module is updated you will have to do this all over again. Also you will have to change this file if the order of the options change.

fra_ore_90’s picture

Hi, I don't undestrand what corrispond this: Lake Travis???

In my case always returns - Any - because i dont know how set the: data.data[0].label == ????

blackmyers87’s picture

The data.data[0].label is your first value of your field.

Siriki’s picture

Hi b777,

I created select hierarchy ( taxonomy with 3 levels), but in default it shows only one level , how can I display all 3 level in default page?

Example: State,City,Branch

It was displayed default is country "None".

But I want to display all 3 fields defaultly None.

Please help me...

Thanks..!

fishfree’s picture

@Siriki I have the same problem. Have you solved it?