Created
March 28, 2013 15:27
-
-
Save Cyberschorsch/5264059 to your computer and use it in GitHub Desktop.
Complete Option Form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Define the options form to enable selection of flags. | |
*/ | |
function options_form(&$form, &$form_state) { | |
// Load all flags and types of each flag. | |
$flags = flag_get_flags('taxonomy_term'); | |
// Combine all types (=vocabs) into one option array. | |
$flag_types = array(); | |
$flag_options = array(); | |
foreach ($flags as $flagname => $value) { | |
// $flag_types is the array storing all vocabs. | |
$flag_types = array_merge($flag_types, $value->types); | |
// $flag_options is the array storing all possible Flags. | |
$flag_options[$flagname] = $flagname; | |
} | |
$form['flags'] = array( | |
'#type' => 'checkboxes', | |
'#title' => t('Choose the Flags'), | |
'#options' => $flag_options, | |
'#process' => array('form_process_checkboxes'), | |
'#default_value' => $this->options['flags'], | |
); | |
$form['vocabularies'] = array( | |
'#type' => 'checkboxes', | |
'#title' => t('Choose the Vocabularies'), | |
'#options' => drupal_map_assoc($flag_types), | |
'#process' => array('form_process_checkboxes'), | |
'#default_value' => $this->options['vocabularies'], | |
); | |
$form['fallback'] = array( | |
'#type' => 'textfield', | |
'#title' => t('Fallback value'), | |
'#description' => t('Value to use, when no item is flagged'), | |
'#default_value' => $this->options['fallback'], | |
); | |
$form['multiple_operator'] = array( | |
'#type' => 'select', | |
'#options' => array( | |
'+' => 'OR', | |
',' => 'AND', | |
), | |
'#title' => t('Operator for multiple values'), | |
'#default_value' => $this->options['multiple_operator'], | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment