function flag_entity::options_form in Flag 7.3
Same name and namespace in other branches
- 7.2 flag.inc \flag_entity::options_form()
Options form extras for the generic entity flag.
Overrides flag_flag::options_form
3 calls to flag_entity::options_form()
- flag_comment::options_form in includes/
flag/ flag_comment.inc - Options form extras for comment flags.
- flag_node::options_form in includes/
flag/ flag_node.inc - Options form extras for node flags.
- flag_user::options_form in includes/
flag/ flag_user.inc - Options form extras for user flags.
3 methods override flag_entity::options_form()
- flag_comment::options_form in includes/
flag/ flag_comment.inc - Options form extras for comment flags.
- flag_node::options_form in includes/
flag/ flag_node.inc - Options form extras for node flags.
- flag_user::options_form in includes/
flag/ flag_user.inc - Options form extras for user flags.
File
- includes/
flag/ flag_entity.inc, line 37 - Contains the flag_entity class.
Class
- flag_entity
- Base entity flag handler.
Code
function options_form(&$form) {
$bundles = array();
$entity_info = entity_get_info($this->entity_type);
foreach ($entity_info['bundles'] as $bundle_key => $bundle) {
$bundles[$bundle_key] = check_plain($bundle['label']);
}
$form['access']['types'] = array(
'#type' => 'checkboxes',
'#title' => t('Bundles'),
'#options' => $bundles,
'#description' => t('Select the bundles that this flag may be used on. Leave blank to allow on all bundles for the entity type.'),
'#default_value' => $this->types,
);
// Add checkboxes to show flag link on each entity view mode.
$options = array();
$defaults = array();
$entity_view_modes = $entity_info['view modes'];
foreach ($entity_view_modes as $name => $view_mode) {
$options[$name] = t('Display on @name view mode', array(
'@name' => $view_mode['label'],
));
$defaults[$name] = !empty($this->show_in_links[$name]) ? $name : 0;
}
// Select the first display option by default if this is a new flag.
if (empty($this->fid)) {
$first_view_mode_keys = array_keys($entity_view_modes);
$first_view_mode = reset($first_view_mode_keys);
$defaults[$first_view_mode] = $first_view_mode;
}
$form['display']['show_in_links'] = array(
'#type' => 'checkboxes',
'#title' => t('Display in entity links'),
'#description' => t('Show the flag link with the other links on the entity.'),
'#options' => $options,
'#default_value' => $defaults,
);
$form['display']['show_as_field'] = array(
'#type' => 'checkbox',
'#title' => t('Display link as field'),
'#description' => t('Show the flag link as a pseudofield, which can be ordered among other entity elements in the "Manage display" settings for the entity type.'),
'#default_value' => isset($this->show_as_field) ? $this->show_as_field : TRUE,
);
if (empty($entity_info['fieldable'])) {
$form['display']['show_as_field']['#disabled'] = TRUE;
$form['display']['show_as_field']['#description'] = t("This entity type is not fieldable.");
}
$form['display']['show_on_form'] = array(
'#type' => 'checkbox',
'#title' => t('Display checkbox on entity edit form'),
'#default_value' => $this->show_on_form,
'#weight' => 5,
);
// We use FieldAPI to put the flag checkbox on the entity form, so therefore
// require the entity to be fielable. Since this is a potential DX
// headscratcher for a developer wondering where this option has gone,
// we disable it and explain why.
if (empty($entity_info['fieldable'])) {
$form['display']['show_on_form']['#disabled'] = TRUE;
$form['display']['show_on_form']['#description'] = t('This is only possible on entities which are fieldable.');
}
$form['display']['show_contextual_link'] = array(
'#type' => 'checkbox',
'#title' => t('Display in contextual links'),
'#default_value' => $this->show_contextual_link,
'#description' => t('Note that not all entity types support contextual links.'),
'#access' => module_exists('contextual'),
'#weight' => 10,
);
}