hook_def_field_types

Definition

hook_def_field_types($op)
importexportapi/docs/developer/hooks/importexportapi.php, line 98

Description

Define certain characteristics of one or more field types.

Parameters

$op What kind of characteristics are being sought. Possible values:

  • "placeholders": The placeholder to be used when constructing SQL queries that involve the specified field types.
  • "defaults": The default property values for each field type.

Return value

This varies depending on the operation.

  • The "placeholders" operation should return an array in the form $field => $placeholder.
  • The "defaults" operation should return an array in the form $field => array('property1' => 'default1', ...).

Related topics

Namesort iconDescription
HooksAllow modules to interact with the Drupal core.

Code

<?php
function hook_def_field_types($op) {
  $type = array();

  switch ($op) {
    case 'placeholders':
      $type['int'] = '%d';
      $type['float'] = '%f';
      $type['string'] = "'%s'";
      $type['file'] = "'%s'";
      $type['freeform'] = "'%s'";
      $type['serialized'] = "'%s'";
      $type['datetime'] = "'%s'";
      break;
    case 'defaults':
      $type['int'] = array('#required' => FALSE, '#default_value' => 0);
      $type['float'] = array('#required' => FALSE, '#default_value' => 0.0);
      $type['string'] = array('#required' => FALSE, '#default_value' => '');
      $type['file'] = array('#required' => FALSE, '#default_value' => '');
      $type['freeform'] = array('#required' => FALSE, '#default_value' => array(), '#process' => array('importexportapi_process_freeform' => array()));
      $type['serialized'] = array('#required' => FALSE, '#default_value' => '', '#process' => array('importexportapi_process_serialized' => array()));
      $type['datetime'] = array('#required' => FALSE, '#default_value' => '', '#process' => array('importexportapi_process_datetime' => array()));
      $type['array'] = array('#process' => array('importexportapi_process_array' => array()));
      $type['entity'] = array();
      break;
  }

  return $type;
}
?>