Alter a form in a block only if it is in a certain region In my template.php I'm trying to alter a form in a views exposed block, but I only want to do this if that block is in a certain region in my theme.

I'm using Drupal 7.

Is that possible? What php code would I use?

Here is what I'm using now:

function cmfzen_form_alter(&amp;$form, &amp;$form_state, $form_id) {

  // change the main search form
  // see http://drupal.stackexchange.com/questions/28404/easiest-way-to-add-x-webkit-speech-to-the-search-blocks-input-element
  // see http://adaptivethemes.com/html5-placeholder-text-for-your-drupal-7-search-field
  if ($form_id == "views_exposed_form" &amp;&amp; $form['#id'] == "views-exposed-form-site-search-page"){

    $form['site-search']['#type'] = 'searchfield';
    $form['site-search']['#attributes'] = array(
      'class' =&gt; array('search-site'),
      'placeholder' =&gt; t("I'm looking for..."),
      'speech x-webkit-speech spellcheck' =&gt; 'false',
      );
    // change form submit button

    $form['submit']['#attributes'] = array('class' =&gt; array('search-button'));
  }
}
use this code in hook_form_alter:

function cmfzen_form_alter(&amp;$form, &amp;$form_state, $form_id) {
    switch($form_id){
         case 'views_exposed_form':
         $region = 'NAME_OF_A_REGION';
         $blocks = block_list($region);
         kpr($blocks);
         //if the block is in the $blocks array do the changes.
         break;
    }
}


using block_list($region) you will get the blocks that are placed in a specific region, and it returns array of block objects (for more detail visit this page). Now check if the block you are looking for is in the $blocks array.