function safeword_context_condition::options_form in Safeword 8
Same name and namespace in other branches
- 7 safeword_context/safeword_context_condition.inc \safeword_context_condition::options_form()
File
- safeword_context/
safeword_context_condition.inc, line 31
Class
Code
function options_form($context) {
$entity_types = array_map(function ($type) {
return $type['label'];
}, entity_get_info());
$options = $this
->fetch_from_context($context, 'options');
return array(
'entity_types' => array(
'#title' => t('Only entity types'),
'#type' => 'checkboxes',
'#options' => $entity_types,
'#description' => t('Leave empty to match all entity types.'),
'#default_value' => isset($options['entity_types']) ? array_filter($options['entity_types']) : array(),
// This gets rid of all the unchecked options that Drupal would normally keep: node => 0, file => 'file' etc.
'#element_validate' => array(
function ($element, &$form_state) {
form_set_value($element, array_filter($element['#value']), $form_state);
},
),
),
);
}