Return to Snippet

Revision: 3985
at October 14, 2007 10:47 by WimLeers


Updated Code
/**
 * Helper function to create a content field (CCK field).
 *
 * @param $type_name
 *   The content type for which the content field should be created.
 * @param $properties
 *   An array with field type properties, that override the default ones.
 */
function _create_content_field($type_name, $properties) {
  $default = array(
    'label' => 'A field label', // Override in $properties
    'widget_type' => '',  // Override in $properties
    'op' => 'Create field',
    'submit' => 'Create field',
    'locked' => FALSE,
    'field_name' => '', // Override in $properties, lowercase underscore
  );

  $new_field = array_merge($default, $properties);
  $new_field['type_name'] = $type_name;

  _content_admin_field_add_new_submit('_content_admin_field_add_new', $new_field);
}

Revision: 3984
at October 14, 2007 07:12 by WimLeers


Updated Code
function _create_content_field($type_name, $properties) {
  $default = array(
    'label' => 'A field label', // Override in $properties
    'field_widget_type' => '',  // Override in $properties
    'op' => 'Create field',
    'submit' => 'Create field',
    'locked' => FALSE,
    'field_name' => '', // Override in $properties, lowercase underscore
  );

  $new_field = array_merge($default, $properties);
  $new_field['type_name'] = $type_name;

  _content_admin_field_add_new_submit('_content_admin_field_add_new', $new_field);
}

Revision: 3983
at October 14, 2007 07:11 by WimLeers


Initial Code
function _create_content_field($type_name, $properties) {
  $default = array(
    'label' => 'A field label', // Override in $properties
    'field_widget_type' => '',  // Override in $properties
    'op' => 'Create field',
    'submit' => 'Create field',
    'locked' => FALSE,
    'field_name' => '', // Override in $properties, lowercase underscore
  );

  $new_field = array_merge($default, $properties);
  $new_field['type_name'] = $type_name;

  _content_admin_field_add_new_submit('_content_admin_field_add_new', $new_field);
}

Initial URL


Initial Description
With thanks to emspace for the original code :)

Initial Title
Helper function to create a content field (CCK field)

Initial Tags
textmate, drupal

Initial Language
PHP