You are here

function mvf_field_mockup in Measured Value Field 7

Supportive function.

Mock up field array of a subfield of the supplied $field array based on the parameter $subfield.

Parameters

array $field: Field that includes sub fields one of which needs to be mocked up

string $subfield: Subfield name for which the sub field array should be mocked up

Return value

array Array of mocked up subfield

22 calls to mvf_field_mockup()
mvf_entityreference_field_settings_validate in ./mvf.module
Supportive validation function.
mvf_field_delete in ./mvf.module
Implements hook_field_delete().
mvf_field_formatter_prepare_view in ./mvf.module
Implements hook_field_formatter_prepare_view().
mvf_field_formatter_settings_form in ./mvf.module
Implements hook_field_formatter_settings_form().
mvf_field_formatter_settings_summary in ./mvf.module
Implements hook_field_formatter_settings_summary().

... See full list

File

./mvf.module, line 1345
Define a field type of measured value.

Code

function mvf_field_mockup($field, $subfield) {
  $mocked_field = array(
    'field_name' => $field['field_name'],
    'translatable' => $field['translatable'],
    'entity_types' => $field['entity_types'],
    'type' => $field['settings']['meta_info'][$subfield]['field_type'],
    'module' => $field['settings']['meta_info'][$subfield]['module'],
    'active' => $field['active'],
    'locked' => $field['locked'],
    // For subfields the cardinality is always 1, we handle cardinality in the
    // real field.
    'cardinality' => 1,
    'deleted' => $field['deleted'],
    'settings' => isset($field['settings'][$subfield]) ? $field['settings'][$subfield] : array(),
    'storage' => $field['storage'],
  );
  if (isset($field['columns'])) {
    $mocked_field['columns'] = $field['columns'];
  }
  if (isset($field['bundles'])) {
    $mocked_field['bundles'] = $field['bundles'];
  }
  return $mocked_field;
}