Hi all, <br> 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<br>To make it simple, I only write some hooks that I think may needed in the module.... <br>
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. <br><br>Here's the code for zebra.module. Did I forget some thing, thanks for your help.<br>
<br><?php<br><br>function zebra_field_info() {<br> return array(<br> 'zebra' => array('label' => 'Zebra field',),<br> );<br>}<br><br>function zebra_field_settings($op, $field) {<br>
switch ($op) {<br> case 'database columns': <br> $columns['value'] = array(<br> 'type' => 'varchar',<br> 'length' => 255,<br>
'not null' => FALSE,<br> 'sortable' => TRUE,<br> );<br> return $columns;<br> };<br>}<br><br>function zebra_field($op, &$node, $field, &$items, $teaser, $page) {<br>
switch ($op) {<br> }<br>}<br><br>function zebra_widget_info() {<br> return array(<br> 'zebra_widget' => array(<br> 'label' => 'Zebra Widget', <br> 'field types' => array('zebra'),<br>
),<br> );<br>}<br><br>function zebra_widget_settings($op, $widget) {<br> switch ($op) {<br> }<br>}<br><br>function zebra_widget($op, &$node, $field, &$items) {<br> $element['value'] = array(<br>
'#type' => 'select', <br> '#title' => t($field['widget']['label']),<br> '#default_value' => variable_get('zebra_widget_value', '0'),<br>
'#options' => array('a', 'b', 'c', 'd'),<br> );<br><br> return $element;<br>}<br clear="all"><br>thanks,<br>-- <br>Zan Guo<br>E-Mail: <a href="mailto:guozan523@gmail.com" target="_blank">guozan523@gmail.com</a><br>
<br>