Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7670693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:52:51+00:00 2026-05-31T15:52:51+00:00

I have a drupal 7 form with a bunch of fields: $form[‘account_type’] = array(

  • 0

I have a drupal 7 form with a bunch of fields:

$form['account_type'] = array(
  '#title' => t('Utility Account Type'),
  '#type' => 'select',
  '#options' => necp_enrollment_administration_portal_account_type_options(),
  '#required' => TRUE,
  '#default_value' => isset($form_state['values']['account_type']) ? $form_state['values']['account_type'] : '',
);

// Should show if account_type = 1
$form['home_wrapper'] = array(
  '#type' => 'fieldset',
  '#states' => array(
    'visible' => array(
      ':input[name="account_type"]' => array('value' => 1),
    ),
  ),
);
$form['home_wrapper']['first_name_1'] = array(
  '#title' => t('Primary Account First Name'),
  '#type' => 'textfield',
  '#default_value' => isset($form_state['values']['first_name_1']) ? $form_state['values']['first_name_1'] : '',
  '#states' => array(
    'required' => array(
      ':input[name="account_type"]' => array('value' => 1),
    ),
  ),
);
$form['home_wrapper']['last_name_1'] = array(
  '#title' => t('Primary Account Last Name'),
  '#type' => 'textfield',
  '#default_value' => isset($form_state['values']['last_name_1']) ? $form_state['values']['last_name_1'] : '',
  '#states' => array(
    'required' => array(
      ':input[name="account_type"]' => array('value' => 1),
    ),
  ),
);

// Should show if account_type = 2
$form['business_wrapper'] = array(
  '#type' => 'fieldset',
  '#states' => array(
    'visible' => array(
      ':input[name="account_type"]' => array('value' => 2),
    ),
  ),
);
$form['business_wrapper']['company_name'] = array(
  '#title' => t('Company/Organization'),
  '#type' => 'textfield',
  '#default_value' => isset($form_state['values']['company_name']) ? $form_state['values']['company_name'] : '',
  '#states' => array(
    'required' => array(
      ':input[name="account_type"]' => array('value' => 2),
    ),
  ),
);

In Firefox/Chrome/Opera all versions this form behaves as it should. However in all versions of IE the form initializes with display:none; style on all of the conditional fields regardless of what the value in account_type is. Changing the selected option of account_type does not effect the hidden status.

Any tips on debugging this form would be awesome.

Notes:

  • I am not much of a Drupal developer, I inherited this site. Just trying to iron out the last couple bugs so we can go live
  • there are more fields than are listed above, I just gave you some of the applicable ones so that you could get the gist of how my forms were setup
  • current url for the form in development: https://northeastcleanpower.com/enroll_new
  • I’m using http://www.browserstack.com/ to debug IE 7 – 10pp4 (I think we only have to support 8 and up though)

I’ve also tried:

  • ':select[name="account_type"]' => array('value' => 1),
  • '#edit-account-type' => array('value' => 1),
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T15:52:52+00:00Added an answer on May 31, 2026 at 3:52 pm

    Ok, I found the solution. Hopefully this will help someone in a similar situation to mine.

    ':input[name="account_type"]' => array('value' => 1),
    

    needed to be:

    ':input[name="account_type"]' => array('value' => "1"),
    

    Apparently, the javascript in IE was evaluating literal type/value not just value: 1 !== "1" etc. Once I fixed this it started working like a champ.

    also there was another instance in my code where the value was coming from a PHP variable, It wouldn’t accept the variable as an int, but accepted it as a string…

    ':input[name="account_type"]' => array('value' => "$id"),
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a drupal form which i post using jquery when you select an
i have form in drupal which uploads images and has got few checkboxes in
I have a Drupal module page where I am populating a form with a
How do you add Search form to your Views in Drupal? Do I have
I have a Drupal setup like this: Content type: Apartments Vocabulary: Areas , that
we have drupal 6 project where one separate content type is AUTHOR where we
I have a Drupal (v6.17) Content Type which includes a Taxonomy field. I want
I have a form field in Drupal which I need some help with. The
I want to have a non-Drupal website create a user account in my Drupal
I have a drupal API of the form function contactus(){ return drupal_get_form('myform_contact'); } function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.