1 node_example.module _node_example_installed_instances()

Define the field instances for our content type.

The instance lets Backdrop know which widget to use to allow the user to enter data and how to react in different view modes. We are going to display a page that uses a custom "node_example_list" view mode. We will set a cardinality of three allowing our content type to give the user three color fields.

This big array is factored into this function for readability.

Return value

array: An associative array specifying the instances we wish to add to our new node type.

Related topics

File

modules/examples/node_example/node_example.module, line 286
Module file for Node Example module.

Code

function _node_example_installed_instances() {
  return array(
    'node_example_color' => array(
      'field_name' => 'node_example_color',
      'label' => t('The colors available for this object.'),
      'widget' => array(
        'type' => 'text_textfield',
      ),
      'display' => array(
        'example_node_list' => array(
          'label' => 'hidden',
          'type' => 'node_example_colors',
        ),
      ),
    ),
    'node_example_quantity' => array(
      'field_name' => 'node_example_quantity',
      'label' => t('Quantity required'),
      'type' => 'text',
      'widget' => array(
        'type' => 'text_textfield',
      ),
      'display' => array(
        'example_node_list' => array(
          'label' => 'hidden',
          'type' => 'hidden',
        ),
      ),
    ),
    'node_example_image' => array(
      'field_name' => 'node_example_image',
      'label' => t('Upload an image:'),
      'required' => FALSE,
      'widget' => array(
        'type' => 'image_image',
        'weight' => 2.10,
      ),
      'display' => array(
        'example_node_list' => array(
          'label' => 'hidden',
          'type' => 'image_link_content__thumbnail',
        ),
      ),
    ),
  );
}