How to filter checkboxes list to only selected items?

setfree - May 15, 2008 - 17:10

When I load the array from:

<?php
// ...

 
$form['bibleplans_plans'] = array(
     
'#type' => 'checkboxes',
     
'#title' => t('Active Bible Plans.'),
     
'#description' => t('Disable any plans that you do not want available to users.'),
     
'#default_value' => variable_get('bibleplans_plans', array()),
     
'#options' => $plans,
    );
// ...

  
$plans = variable_get('bibleplans_plans', array());
?>

How do I filter $plans to be an array of only the selected checkboxes?

Figured it out...

setfree - May 15, 2008 - 17:14

<?php
$plans
= array_filter(variable_get('bibleplans_plans', bible_plans()));
?>

The Cosmic Gift | Complete Computer Care | Team Hope

 
 

Drupal is a registered trademark of Dries Buytaert.