Define field allowed values in your module.codes.inc file.

Why? The core Options module provides allowed values for List type fields.
This is not really usable when you want to work with those values in your custom module, because it could easily break when someone modifies those allowed values.

Codes module has a new field type which provides an alternative way to define allowed values.

How? short example:
mymodule.module

<?php
// Implemets hook_codes_api().
function mymodule_codes_api() {
  return array(
'api' => 1);
}
?>

mymodule.codes.inc

<?php
function mymodule_get_codesets() {
  return array(
   
'type' => 'Type',
   
'status' => 'Status',
  );
}

function
mymodule_get_type_codes() {
  return array(
   
'private' => 'Private',
   
'public' => 'Public',
  );
}

function
mymodule_get_status_codes() {
  return array(
   
'open' => 'Still open!',
   
'closed' => 'Closed',
   
'full' => 'Totally full',
  );
}
?>

Project Information

Downloads