public function entity_views_plugin_row_entity_view::options_form in Entity API 7
Provide a form for setting options.
Overrides views_plugin_row::options_form
File
- views/
plugins/ entity_views_plugin_row_entity_view.inc, line 36 - Row style plugin for displaying the results as entities.
Class
- entity_views_plugin_row_entity_view
- Plugin class for displaying Views results with entity_view.
Code
public function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$entity_info = entity_get_info($this->entity_type);
$options = array();
if (!empty($entity_info['view modes'])) {
foreach ($entity_info['view modes'] as $mode => $settings) {
$options[$mode] = $settings['label'];
}
}
if (count($options) > 1) {
$form['view_mode'] = array(
'#type' => 'select',
'#options' => $options,
'#title' => t('View mode'),
'#default_value' => $this->options['view_mode'],
);
}
else {
$form['view_mode_info'] = array(
'#type' => 'item',
'#title' => t('View mode'),
'#description' => t('Only one view mode is available for this entity type.'),
'#markup' => $options ? current($options) : t('Default'),
);
$form['view_mode'] = array(
'#type' => 'value',
'#value' => $options ? key($options) : 'default',
);
}
return $form;
}