Add an inventory field collection with asset and value fields.
This commit is contained in:
parent
a68b918b87
commit
40c248a29e
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* farm_inventory.features.field_base.inc
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_field_default_field_bases().
|
||||
*/
|
||||
function farm_inventory_field_default_field_bases() {
|
||||
$field_bases = array();
|
||||
|
||||
// Exported field_base: 'field_farm_inventory'.
|
||||
$field_bases['field_farm_inventory'] = array(
|
||||
'active' => 1,
|
||||
'cardinality' => -1,
|
||||
'deleted' => 0,
|
||||
'entity_types' => array(),
|
||||
'field_name' => 'field_farm_inventory',
|
||||
'indexes' => array(
|
||||
'revision_id' => array(
|
||||
0 => 'revision_id',
|
||||
),
|
||||
'value' => array(
|
||||
0 => 'value',
|
||||
),
|
||||
),
|
||||
'locked' => 0,
|
||||
'module' => 'field_collection',
|
||||
'settings' => array(
|
||||
'hide_blank_items' => 1,
|
||||
'hide_initial_item' => 1,
|
||||
'path' => '',
|
||||
),
|
||||
'translatable' => 0,
|
||||
'type' => 'field_collection',
|
||||
);
|
||||
|
||||
// Exported field_base: 'field_farm_inventory_asset'.
|
||||
$field_bases['field_farm_inventory_asset'] = array(
|
||||
'active' => 1,
|
||||
'cardinality' => 1,
|
||||
'deleted' => 0,
|
||||
'entity_types' => array(),
|
||||
'field_name' => 'field_farm_inventory_asset',
|
||||
'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(),
|
||||
),
|
||||
'target_type' => 'farm_asset',
|
||||
),
|
||||
'translatable' => 0,
|
||||
'type' => 'entityreference',
|
||||
);
|
||||
|
||||
// Exported field_base: 'field_farm_inventory_value'.
|
||||
$field_bases['field_farm_inventory_value'] = array(
|
||||
'active' => 1,
|
||||
'cardinality' => 1,
|
||||
'deleted' => 0,
|
||||
'entity_types' => array(),
|
||||
'field_name' => 'field_farm_inventory_value',
|
||||
'indexes' => array(),
|
||||
'locked' => 0,
|
||||
'module' => 'fraction',
|
||||
'settings' => array(),
|
||||
'translatable' => 0,
|
||||
'type' => 'fraction',
|
||||
);
|
||||
|
||||
return $field_bases;
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* farm_inventory.features.field_instance.inc
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_field_default_field_instances().
|
||||
*/
|
||||
function farm_inventory_field_default_field_instances() {
|
||||
$field_instances = array();
|
||||
|
||||
// Exported field_instance:
|
||||
// 'field_collection_item-field_farm_inventory-field_farm_inventory_asset'.
|
||||
$field_instances['field_collection_item-field_farm_inventory-field_farm_inventory_asset'] = array(
|
||||
'bundle' => 'field_farm_inventory',
|
||||
'deleted' => 0,
|
||||
'description' => 'Which asset do you want to adjust the inventory of?',
|
||||
'display' => array(
|
||||
'default' => array(
|
||||
'label' => 'inline',
|
||||
'module' => 'entityreference',
|
||||
'settings' => array(
|
||||
'bypass_access' => 0,
|
||||
'link' => 1,
|
||||
),
|
||||
'type' => 'entityreference_label',
|
||||
'weight' => 0,
|
||||
),
|
||||
),
|
||||
'entity_type' => 'field_collection_item',
|
||||
'field_name' => 'field_farm_inventory_asset',
|
||||
'label' => 'Asset',
|
||||
'required' => 1,
|
||||
'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_asset_entityreference_view|entityreference_view_widget',
|
||||
'view_mode' => 'full',
|
||||
),
|
||||
'type' => 'entityreference_view_widget',
|
||||
'weight' => 0,
|
||||
),
|
||||
);
|
||||
|
||||
// Exported field_instance:
|
||||
// 'field_collection_item-field_farm_inventory-field_farm_inventory_value'.
|
||||
$field_instances['field_collection_item-field_farm_inventory-field_farm_inventory_value'] = array(
|
||||
'bundle' => 'field_farm_inventory',
|
||||
'default_value' => NULL,
|
||||
'deleted' => 0,
|
||||
'description' => 'Enter a positive value to record an increase in inventory. Enter a negative value to record a decrease in inventory.',
|
||||
'display' => array(
|
||||
'default' => array(
|
||||
'label' => 'inline',
|
||||
'module' => 'fraction',
|
||||
'settings' => array(
|
||||
'auto_precision' => TRUE,
|
||||
'precision' => 0,
|
||||
'prefix_suffix' => TRUE,
|
||||
),
|
||||
'type' => 'fraction_decimal',
|
||||
'weight' => 2,
|
||||
),
|
||||
),
|
||||
'entity_type' => 'field_collection_item',
|
||||
'field_name' => 'field_farm_inventory_value',
|
||||
'label' => 'Value',
|
||||
'required' => 1,
|
||||
'settings' => array(
|
||||
'max' => '',
|
||||
'min' => '',
|
||||
'prefix' => '',
|
||||
'suffix' => '',
|
||||
'user_register_form' => FALSE,
|
||||
),
|
||||
'widget' => array(
|
||||
'active' => 1,
|
||||
'module' => 'fraction',
|
||||
'settings' => array(
|
||||
'auto_precision' => 1,
|
||||
'precision' => 0,
|
||||
),
|
||||
'type' => 'fraction_decimal',
|
||||
'weight' => 1,
|
||||
),
|
||||
);
|
||||
|
||||
// Translatables
|
||||
// Included for use with string extractors like potx.
|
||||
t('Asset');
|
||||
t('Enter a positive value to record an increase in inventory. Enter a negative value to record a decrease in inventory.');
|
||||
t('Value');
|
||||
t('Which asset do you want to adjust the inventory of?');
|
||||
|
||||
return $field_instances;
|
||||
}
|
|
@ -2,3 +2,16 @@ name = Farm Inventory
|
|||
description = Provides inventory management functionality for farm assets.
|
||||
core = 7.x
|
||||
package = farmOS
|
||||
dependencies[] = entityreference
|
||||
dependencies[] = entityreference_view_widget
|
||||
dependencies[] = features
|
||||
dependencies[] = field_collection
|
||||
dependencies[] = fraction
|
||||
dependencies[] = list
|
||||
dependencies[] = options
|
||||
features[features_api][] = api:2
|
||||
features[field_base][] = field_farm_inventory
|
||||
features[field_base][] = field_farm_inventory_asset
|
||||
features[field_base][] = field_farm_inventory_value
|
||||
features[field_instance][] = field_collection_item-field_farm_inventory-field_farm_inventory_asset
|
||||
features[field_instance][] = field_collection_item-field_farm_inventory-field_farm_inventory_value
|
||||
|
|
Loading…
Reference in New Issue