public function DateRestrictionsHostEntityMinMaxTestCase::createIntervalField in Date Restrictions 7
Creates a field of type interval and an instance attached to the 'story' bundle of node entity type. That bundle is created in DateFieldBasic::setUp().
1 call to DateRestrictionsHostEntityMinMaxTestCase::createIntervalField()
- DateRestrictionsHostEntityMinMaxTestCase::setUp in modules/
minmax/ tests/ date_restrictions_minmax_host_entity.test - Creates a field for each date field type.
File
- modules/
minmax/ tests/ date_restrictions_minmax_host_entity.test, line 211 - Tests for date_restrictions_minmax.module.
Class
- DateRestrictionsHostEntityMinMaxTestCase
- Tests for host_entity based relative/fixed minmax restrictions.
Code
public function createIntervalField($values) {
extract($values);
$field = array(
'settings' => array(),
'field_name' => $field_name,
'type' => 'interval',
'cardinality' => '1',
);
$instance = array(
'label' => $label,
'widget' => array(
'type' => 'interval_default',
'module' => 'interval',
'active' => 0,
'settings' => array(),
),
'settings' => array(
'allowed_periods' => array(
'day' => 'day',
'second' => 0,
'minute' => 0,
'hour' => 0,
'month' => 0,
'year' => 0,
'week' => 0,
'fortnight' => 0,
'quarter' => 0,
),
),
'display' => array(
'default' => array(
'label' => 'above',
'type' => 'interval_default',
'settings' => array(),
'module' => 'interval',
),
),
'required' => 0,
'description' => '',
'default_value' => NULL,
'field_name' => $field_name,
'entity_type' => 'node',
'bundle' => 'story',
);
$field = field_create_field($field);
$instance = field_create_instance($instance);
}