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 962177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:27:50+00:00 2026-05-16T01:27:50+00:00

This is a Drupal Forms question. I am working on a UI that dynamically

  • 0

This is a Drupal Forms question.

I am working on a UI that dynamically creates rows of 3 radio buttons based on a selected date. The problem I am having is that if I make some selections of the radio buttons and choose another date to get another set of radio buttons, the radios that were in the first list maintain their selected status and ignore the ‘#default_value’ attribute.

What I want is when a new date is selected is that all the dynamically created radios to be unselected. The only way i can think of now is to create some unique key to use in the radios name for each set of radios.

  • 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-16T01:27:51+00:00Added an answer on May 16, 2026 at 1:27 am

    here is part of the code that creates the rows of radio buttons. For each row in $result, I need to create a row of 4 radio buttons. I also try to set the #default_value of the radio buttons to what ever value was previous selected. This is fine for the initial submit, but if i make changes, and don’t save, and want to get the original selected values, it maintains the currently selected values.

    while ($my_data = db_fetch_object($result))
    {   
      $form['opts'][$my_data->opt_id] = array(
        '#type' => 'radios',
        '#title' => t($my_data->option_name),
            '#options' => array(
             0 => 'N/A',
             1 => 'Yes', 
             2 => 'No',
             3 => 'Sometimes',
             ),
       );
    
       $form['opts'][$my_data->opt_id]['#default_value'] =  0;
       if($my_data->selected_opt_id != 0){
         $form['opts'][$my_data->opt_id]['#default_value'] =  $my_data->selected_opt_id;
       }
    }
    

    What I ended up doing was using JavaScript to set the default values every time the listing is requested. I think the issue was that “#default_value” is only good for controlling the initial view of the form, and isn’t used on postback. Anyone can confirm?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I asked this question about reasons to use Drupal 7's Forms API as opposed
This is as equally a drupal question as a PHP question, I assume. I
I have a Drupal setup like this: Content type: Apartments Vocabulary: Areas , that
I am probably asking a noob question... however: I have a Drupal site that
I need to customise my forms in drupal so that each field has a
I'm new to Drupal & PHP. I have a similar problem to this unanswered
I don't think this is a Drupal-specific question, but more of a general jquery/ajax
I'm having a problem with Drupal forms. Can't think of a way to solve
I have this basic Drupal scenario and question: I have a form which accepts
Im working on a drupal site that uses jQtouch (for iphone), and im trying

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.