Create a float field programmatically in Drupal
$field = array(
'field_name' => 'field_amount',
'type' => 'number_float',
'cardinality' => 1,
);
field_create_field($field);
$instance = array(
'field_name' => 'field_amount',
'entity_type' => 'transaction',
'bundle' => 'payment',
'label' => 'amount',
'cardinality' => 1,
'settings' => array(
'text_processing' => TRUE,
'prefix' => 'US$',
),
'widget' => array(
'type' => 'number',
'settings' => array('size' => 60),
),
'display' => array(
'full' => array(
'type' => 'text_default',
),
),
);
field_create_instance($instance);
```
Written by Rafael Caceres
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#