[development] write a simple field type for CCK
Peter Droogmans
Peter at attiks.com
Sun Feb 26 17:37:43 UTC 2012
Dear,
This list is for Drupal core development, regarding your question: this is possible with standard cck module.
Cheers
Peter Droogmans
From: development-bounces at drupal.org [mailto:development-bounces at drupal.org] On Behalf Of ??
Sent: zondag 26 februari 2012 16:22
To: development at drupal.org
Subject: [development] write a simple field type for CCK
Hi all,
I'm new to drupal module development, and want to write a simple field type for CCK, just to give a list for user to select, and then store the value. Drupal Verison is 6.22
To make it simple, I only write some hooks that I think may needed in the module....
and things get wrong, the row in the table is created in the database, but the field is not able to store data in the database, when I click submit, the page comes to be blank.
Here's the code for zebra.module. Did I forget some thing, thanks for your help.
<?php
function zebra_field_info() {
return array(
'zebra' => array('label' => 'Zebra field',),
);
}
function zebra_field_settings($op, $field) {
switch ($op) {
case 'database columns':
$columns['value'] = array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'sortable' => TRUE,
);
return $columns;
};
}
function zebra_field($op, &$node, $field, &$items, $teaser, $page) {
switch ($op) {
}
}
function zebra_widget_info() {
return array(
'zebra_widget' => array(
'label' => 'Zebra Widget',
'field types' => array('zebra'),
),
);
}
function zebra_widget_settings($op, $widget) {
switch ($op) {
}
}
function zebra_widget($op, &$node, $field, &$items) {
$element['value'] = array(
'#type' => 'select',
'#title' => t($field['widget']['label']),
'#default_value' => variable_get('zebra_widget_value', '0'),
'#options' => array('a', 'b', 'c', 'd'),
);
return $element;
}
thanks,
--
Zan Guo
E-Mail: guozan523 at gmail.com<mailto:guozan523 at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20120226/f6a5cee0/attachment.html
More information about the development
mailing list