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

  • Home
  • SEARCH
  • 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 9076291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:04:44+00:00 2026-06-16T19:04:44+00:00

So I have a form as shown bellow. its a bit long. It contains

  • 0

So I have a form as shown bellow. its a bit long. It contains three radio boxes. Every time I select one, doesn’t matter which, and then hit submit, the last radio element shows up as selected instead of the one I clicked. I var dump the option (in this case aisis_core[‘display_rows’]) and it will say the value of the radio element i selected instead of the current on selected.

So I select lists, it will show lists but the radio box selected is no_posts. Can some one tell me what I am doing wrong?

 <form action="options.php" method="post">
   <input type='hidden' name='option_page' value='aisis_options' /><input type="hidden"
   name="action" value="update" /><input type="hidden" id="_wpnonce" name="_wpnonce"
   value="f0385965c6" /><input type="hidden" name="_wp_http_referer" value=
   "/WordPressDev/wp-admin/admin.php?page=aisis-core-options&amp;settings-updated=true" />
     <fieldset>
       <div class="control-group">
         <label class="radio"><input type="radio" id="rows" class="display" name=
         "aisis_core[display_rows]" value="display_rows" checked="checked" /> Display
         posts as rows. <a href="#radioRows" data-toggle="modal"></a></label>

         <div class="control-group">
           <label class="radio"><input type="radio" class="display" name=
           "aisis_core[display_rows]" value="list" checked="checked" /> Display posts a
           list. <a href="#radioLists" data-toggle="modal"></a></label>
         </div>

         <div class="control-group">
           <label class="radio"><input type="radio" id="noDisplay" class="display" name=
           "aisis_core[display_rows]" value="no_posts" checked="checked" /> Display no
           posts.</label>

           <div class="no_posts_section borderBottom">
             <div class="well headLine">
               <h1>Display No Rows</h1>

               <p>If you choose to display no rows please give me a url of the page or
               content you would like to display instead.</p>

               <p class="text-info"><strong>Note:</strong> Formatting of said content is
               up you. All we do is display it.</p>
             </div>

             <div class="control-group">
               <div class="controls">
                 <input type="url" name="aisis_core[index_page_no_posts]" value=
                 "http://google.ca" placeholder="Url" />
               </div>
             </div>
           </div>

           <div class="control-group">
             <div class="form-actions">
               <input type="submit" class="btn btn-primary btn-large" />
             </div>
           </div>
         </div>
       </div>
     </fieldset>
   </form>

The function I am using from wordpress is:

checked('radio_box_value', isset($options['display_rows']), false)

Note: radio_box_value is replaced with what ever the value of the radio box is.

In this case only the last radio box has the “checked” in it’s tag, when it should be which ever one I chose.

How are the elements being created?

The following is how I create the elements, they print out what you see above in the html for the radio buttons. These are done similar to, but not exactly, zend framework.

Its pretty straight forward what were doing, create the element, add the options to the element and then return it.
I hope this gives a better picture as to how these are being created.

protected function _radio_rows_element(){
    $options = get_option('aisis_core');
    echo $options['display_rows'];
    $radio_element = array(
        'name' => 'aisis_core[display_rows]',
        'value' => 'display_rows',
        'class' => 'display',
        'id' => 'rows',
        'checked' => checked('display_rows', isset($options['display_rows']) && $options['display_rows'] == 'display_rows', false),
        'label' => ' Display posts as rows. <a href="#radioRows" data-toggle="modal">
            <i class="icon-info-sign"> </i></a>'        
    );

    $radio = new CoreTheme_Form_Elements_Radio($radio_element, $this->sub_section_rows_array());

    return $radio;
}

protected function _radio_list_element(){
    $options = get_option('aisis_core');
    echo $options['display_rows'];
    $radio_element = array(
            'name' => 'aisis_core[display_rows]',
            'value' => 'list',
            'class' => 'display',
            'checked' => checked('list', isset($options['display_rows']) && $options['display_rows'] == 'list', false),
            'label' => ' Display posts a list. <a href="#radioLists" data-toggle="modal">
            <i class="icon-info-sign"> </i></a>'
    );

    $radio = new CoreTheme_Form_Elements_Radio($radio_element);
    return $radio;
}

protected function _radio_no_posts_element(){
    $options = get_option('aisis_core');
    echo $options['display_rows'];
    $radio_element = array(
            'name' => 'aisis_core[display_rows]',
            'value' => 'no_posts',
            'class' => 'display',
            'id' => 'noDisplay',
            'checked' => checked('no_posts', isset($options['display_rows']) && $options['display_rows'] == 'no_posts', false),
            'label' => ' Display no posts.</a>'
    );

    $radio = new CoreTheme_Form_Elements_Radio($radio_element, $this->_sub_section_now_posts_array());
    return $radio;
}
  • 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-06-16T19:04:45+00:00Added an answer on June 16, 2026 at 7:04 pm

    I did manage to write this:

    public function set_element_checked($value, $option, $key){
        $options = get_option($option);
        if(isset($options[$key]) && $options[$key] == $value){
            return 'checked';
        }
    }
    

    which does exactly what I want. compare the element value to that of the $option[$key] and if they match return checked. can be called via:

    'checked' => set_element_checked('display_rows', 'aisis_core', 'display_rows');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have built a simple registration form shown below and Iam trying to get
I have a form that searches my local database. Its still in its production
I have a form with a button whose initial value is 'Submit' and its
I have multiple select boxes on the page all of which share the same
I have a heredoc form (shown below) inside addToDb.php. The form posts back to
I have a form that shows results from a database query, these results can
I'm developing a site using the CakePHP framework. I have a form which shows
I have this simple form which shows a pop up calendar when clicked on
I have a form with a list that shows information from a database. I
I have a form which lets you add names to the table and shows

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.