function bat_event_type_add_event_state_reference in Booking and Availability Management Tools for Drupal 7
Same name and namespace in other branches
- 8 modules/bat_event/bat_event.module \bat_event_type_add_event_state_reference()
Create a field of type 'Bat Event State Reference' to reference an Event State.
1 call to bat_event_type_add_event_state_reference()
- BatEventTypeController::save in modules/
bat_event/ bat_event.module
File
- modules/
bat_event/ bat_event.module, line 154 - Manage Events - Events store the EventValue of a Unit over a period of time.
Code
function bat_event_type_add_event_state_reference($entity) {
field_info_cache_clear();
// "event_state_reference" field.
if (field_read_field('event_state_reference') === FALSE) {
$field = array(
'field_name' => 'event_state_reference',
'type' => 'bat_event_state_reference',
'cardinality' => 1,
'locked' => 1,
'settings' => array(),
);
field_create_field($field);
}
field_cache_clear();
// "event_state_reference" field instance.
if (field_read_instance('bat_event', 'event_state_reference', $entity->type) === FALSE) {
$instance = array(
'field_name' => 'event_state_reference',
'entity_type' => 'bat_event',
'label' => 'State',
'bundle' => $entity->type,
'required' => FALSE,
'widget' => array(
'type' => 'bat_event_reference_autocomplete',
),
'settings' => array(
'event_type' => $entity->type,
),
);
field_create_instance($instance);
}
}