I'm attempting to create a a form using the Form API and I'm unable to get checkboxes and radio buttons working properly. Although they show up in the form, only the first option of each one is displayed, that option is displayed with the title of the form:
I also have a select box on the page which is displaying fine, and I'm passing through the values to the select the same way I'm passing it through to the radio/checkboxes, with an array.
How do you pass values through to the #options parameter for checkboxes and radios, or do I simply having a careless error somewhere in my code (featured below)?
Code for the radio buttons and checkboxes:
$facts = array( 'Ponycon' => t('Attended Ponycon'), 'PurhcaseMerch' => t('Purhcased My Little Pony: Friendship is Magic merchandise (dolls, cards, shirts, et cetera)'), 'PurchaseShow' => t('Purhcased Episodes'), 'Meetups' => t('Attended Brony meet-ups'), 'Fanclubs' => t('Part of a MY Little Pony: Friendship is Magic fanclub (Facebook, local, et cetera)'), ); $form['fan_activities'] = array( '#type' => 'checkbox', '#title' => t('Which of the following have you done?'), '#options' => $facts, '#description' => t('Brony activities'), ); $fdisc = array( 'friend' => t('A friend told me about it'), 'ads' => t('Advertisments (commercials, billboards, et certera)'), 'Internet' => t('The internet, but not through an ad (forum, website article, et cetera)'), 'Other' => t('Other'), ); $form['discoverry'] = array( '#type' => 'radio', '#title' => t('How did you first hear about My Little Pony: Friendship is Magic?'), '#options' => $fdisc, '#description' => t('How you discovered the show'), );
Code for the working select box:
$fchoices = array( 'RainbowDash' => t('Rainbow Dash'), 'TwilightSparkle' => t('Twilight Sparkle'), 'Rarity' => t('Rarity'), 'PinkiePie' => t('Pinkie Pie'), 'Fluttershy' => t('Fluttershy'), 'Applejack' => t('Applejack'), ); $form['favpony_area']['favpony'] = array( '#type' => 'select', '#title' => t('Who is your favourite Pony from the mane six?'), '#options' => $fchoices, '#default_value' => variable_get('favpony', 'RainbowDash'), '#description' => t('Your favourite Pony frmo the mane six'), );