function bat_booking_add_start_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_start_date_field()
Add "Start Date" field.
1 call to bat_booking_add_start_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 528
Code
function bat_booking_add_start_date_field($type_bundle) {
field_info_cache_clear();
// "booking_start_date" field.
if (field_read_field('booking_start_date') === FALSE) {
$field = array(
'field_name' => 'booking_start_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_start_date" field instance.
if (field_read_instance('bat_booking', 'booking_start_date', $type_bundle) === FALSE) {
$instance = array(
'field_name' => 'booking_start_date',
'entity_type' => 'bat_booking',
'label' => 'Start 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);
}
}