Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I was just curious of the proper way to set the default value to NONE when creating the date field via PHP code as follows. I have tried setting the default_value parameter to NULL and none without success:
<?php
$fields_array = array(
array(
'field' => array(
'field_name' => 'field_test_date',
'type' => 'datetime',
'cardinality' => 1,
'label' => 'Calendar',
'settings' => array(),
),
'instance' => array(
'field_name' => 'field_test_date',
'entity_type' => 'field_collection_item',
'bundle' => 'field_test_c',
'label' => 'Calendar',
'cardinality' => 1,
'description' => '',
'#default_value' => NULL,
'widget' => array(
'type' => 'text_textfield',
'weight' => 0,
'settings' => array('size' => 50),
),
'display' => array(
'default' => array(
'label' => 'above',
'settings' => array(),
'weight' => 1,
),
'teaser' => array(
'label' => 'above',
'settings' => array(),
'type' => 'hidden',
),
),
'required' => FALSE,
)
),
);
?>