function bat_booking_add_end_date_field in Booking and Availability Management Tools for Drupal 7
Same name and namespace in other branches
- 8 modules/bat_booking/bat_booking.module \bat_booking_add_end_date_field()
Add "End Date" field.
1 call to bat_booking_add_end_date_field()
- bat_booking_entity_insert in modules/
bat_booking/ bat_booking.module - Implements hook_entity_insert().
File
- modules/
bat_booking/ bat_booking.module, line 586
Code
function bat_booking_add_end_date_field($type_bundle) {
field_info_cache_clear();
// "booking_end_date" field.
if (field_read_field('booking_end_date') === FALSE) {
$field = array(
'field_name' => 'booking_end_date',
'type' => 'datetime',
'cardinality' => 1,
'locked' => 1,
'settings' => array(
'cache_count' => 4,
'cache_enabled' => 0,
'granularity' => array(
'day' => 'day',
'hour' => 'hour',
'minute' => 'minute',
'month' => 'month',
'second' => 0,
'year' => 'year',
),
'profile2_private' => FALSE,
'timezone_db' => '',
'todate' => '',
'tz_handling' => 'none',
),
);
field_create_field($field);
}
field_cache_clear();
// "booking_end_date" field instance.
if (field_read_instance('bat_booking', 'booking_end_date', $type_bundle) === FALSE) {
$instance = array(
'field_name' => 'booking_end_date',
'entity_type' => 'bat_booking',
'label' => 'End Date',
'bundle' => $type_bundle,
'required' => FALSE,
'widget' => array(
'type' => 'date_popup',
),
'settings' => array(
'default_value' => 'blank',
'default_value2' => 'same',
'default_value_code' => '',
'default_value_code2' => '',
'user_register_form' => FALSE,
),
);
field_create_instance($instance);
}
}