View source
<?php
include_once 'farm_equipment_field.features.inc';
function farm_equipment_farm_fields_dynamic_bases() {
return array(
'field_farm_equipment' => array(
'active' => 1,
'cardinality' => -1,
'deleted' => 0,
'entity_types' => array(),
'field_name' => 'field_farm_equipment',
'indexes' => array(
'target_id' => array(
0 => 'target_id',
),
),
'locked' => 0,
'module' => 'entityreference',
'settings' => array(
'handler' => 'base',
'handler_settings' => array(
'behaviors' => array(
'views-select-list' => array(
'status' => 0,
),
),
'sort' => array(
'type' => 'none',
),
'target_bundles' => array(
0 => 'equipment',
),
),
'target_type' => 'farm_asset',
),
'translatable' => 0,
'type' => 'entityreference',
),
);
}
function farm_equipment_farm_fields_dynamic_instances() {
$field_instances = array();
$log_types = log_types();
foreach ($log_types as $bundle => $info) {
$field_instances['log-' . $bundle . '-field_farm_equipment'] = array(
'bundle' => $bundle,
'deleted' => 0,
'description' => 'What equipment was used?',
'display' => array(
'default' => array(
'label' => 'inline',
'module' => 'entityreference',
'settings' => array(
'bypass_access' => FALSE,
'link' => 1,
),
'type' => 'entityreference_label',
'weight' => 0,
),
),
'entity_type' => 'log',
'field_name' => 'field_farm_equipment',
'label' => t('Equipment used'),
'required' => 0,
'settings' => array(
'user_register_form' => FALSE,
),
'widget' => array(
'active' => 1,
'module' => 'entityreference_view_widget',
'settings' => array(
'allow_duplicates' => 0,
'close_modal' => 1,
'pass_argument' => 1,
'pass_arguments' => '',
'rendered_entity' => 0,
'view' => 'farm_equipment_entityreference_view|entityreference_view_widget',
'view_mode' => 'full',
),
'type' => 'entityreference_view_widget',
'weight' => 2,
),
);
}
return $field_instances;
}
function farm_equipment_field_ctools_plugin_api($module = NULL, $api = NULL) {
if ($module == "field_group" && $api == "field_group") {
return array(
"version" => "1",
);
}
}
function farm_equipment_field_field_group_info() {
$field_groups = array();
$log_types = log_types();
foreach ($log_types as $bundle => $info) {
$group_name = 'group_farm_equipment';
$entity_type = 'log';
$field_group = new stdClass();
$field_group->disabled = FALSE;
$field_group->api_version = 1;
$field_group->identifier = $group_name . '|' . $entity_type . '|' . $bundle . '|form';
$field_group->group_name = $group_name;
$field_group->entity_type = $entity_type;
$field_group->bundle = $bundle;
$field_group->mode = 'form';
$field_group->parent_name = 'group_farm_tabs';
$field_group->data = array(
'label' => t('Equipment'),
'weight' => '3',
'children' => array(
0 => 'field_farm_equipment',
),
'format_type' => 'fieldset',
'format_settings' => array(
'label' => t('Equipment'),
'instance_settings' => array(
'required_fields' => 1,
'id' => '',
'classes' => 'group-farm-assets field-group-fieldset',
'description' => '',
),
'formatter' => 'open',
),
);
$field_groups[$group_name . '|' . $entity_type . '|' . $bundle . '|form'] = $field_group;
}
return $field_groups;
}
function farm_equipment_field_field_group_info_alter(&$groups) {
foreach ($groups as $key => $group) {
if (empty($group->entity_type)) {
continue;
}
if ($group->entity_type != 'log') {
continue;
}
if ($group->mode != 'form') {
continue;
}
if ($group->group_name != 'group_farm_tabs') {
continue;
}
$groups[$key]->data['children'][] = 'group_farm_equipment';
}
}
function farm_equipment_field_farm_ui_entity_view_groups() {
$groups = array(
'equipment' => array(
'title' => t('Equipment'),
'weight' => 90,
),
);
return $groups;
}
function farm_equipment_field_farm_ui_entity_views($entity_type, $bundle, $entity) {
$views = array();
if ($entity_type == 'farm_asset' && $bundle == 'equipment') {
$views[] = array(
'name' => 'farm_equipment_log',
'group' => 'equipment',
'always' => TRUE,
);
}
return $views;
}