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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:34:51+00:00 2026-06-01T01:34:51+00:00

i have form in drupal which uploads images and has got few checkboxes in

  • 0

i have form in drupal which uploads images and has got few checkboxes in it.
Here is the form:

$form['checklist_fieldset'] = array(
    '#type' => 'fieldset',
    '#title' => t('Check List'),
    '#collapsible' => FALSE,
    '#collapsed' => FALSE,  
  );
$form['checklist_fieldset']['heating'] = array(
   '#type' => 'checkboxes',
   '#title' => t('Heating options'),

   '#options' => array(
  '0' => t('Yes'),
  '1' => t('No')
  ),
   '#description' => t('Heating details.')
  );

and here is my submit function where i am processing image upload and grabbing the checkboxes value as well. I am getting the success message and image is getting uploaded but not getting the value of check boxes.

function property_add_view_submit($form,&$form_state){
$validators = array();



if($file = file_save_upload('p_file1',$validators,file_direcotry_path)){
$heating = array_keys($form_state['values']['heating']);
drupal_set_message(t('Property Saved! '.$heating));
dpm( $form_state['values']['heating']);
}
  • 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-01T01:34:52+00:00Added an answer on June 1, 2026 at 1:34 am

    When you use #options on a FAPI element the value passed to the $form_state is the array key, so you don’t need to use array_keys().

    I’m not sure why you’re using checkboxes for a yes/no, usually one would use a simple checkbox element. However if that’s really what you want to do:

    1. Your #options can’t contain on option with 0 as the array key, it will be automatically filtered out and you’ll never know if that option has been checked.
    2. You should use $heating_options_chosen = array_filter($form_state['values']['heating'] to get the selected checkbox options.

    I honestly think your code should look like this though:

    $form['checklist_fieldset']['heating'] = array(
     '#type' => 'checkbox',
     '#title' => t('Heating options'),
     '#options' => array(
       '1' => t('Yes'),
       '0' => t('No')
      ),
      '#description' => t('Heating details.')
    ); 
    
    
    
    $heating_checked = $form_state['values']['heating'] == 1;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using drupal. I have a form which has a single field, the field
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 have a form with some checkboxes in Drupal and I need to get
I'm using Drupal . I have a module which loads a form onto a
I have a Drupal 7 form which I'm allowing the user to submit via
I've got a hidden field inside a form, which I create using Drupal's form
Using Drupal 6. I've created a new node type with CCK, which has one
I have a drupal form which i post using jquery when you select an
I have this basic Drupal scenario and question: I have a form which accepts

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.