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@gmail.com
Dear, This list is for Drupal core development, regarding your question: this is possible with standard cck module. Cheers Peter Droogmans From: development-bounces@drupal.org [mailto:development-bounces@drupal.org] On Behalf Of ?? Sent: zondag 26 februari 2012 16:22 To: development@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@gmail.com<mailto:guozan523@gmail.com>
On 27/02/12 01:37, Peter Droogmans wrote:
Dear,
This list is for Drupal core development,
Where, then, should those seeking help with module development turn? There's a themes list, but not one for modules. -- John Summerfield
I do agree in this particular case that the question would be more appropriate for the support list. But I also think there should be a development list for programming questions that aren't specific to core. Most of the questions at this level go unanswered on the support list. How many would need to agree to retasking the list before we would be able to ask webchick to make the change? Cameron On Feb 29, 2012, at 8:29 AM, "Ms. Nancy Wichmann" <nan_wich@bellsouth.net> wrote:
The Support list.
From: John Summerfield
Where, then, should those seeking help with module development turn? There's a themes list, but not one for modules.
OMG, we're all a bunch of pedantic buffoons! We've got a mailing list called "development@drupal.org". It gets one email a week. And someone asks a question about how to properly do drupal CCK development, and we send them to another mailing list whilst arguing about whether this list should be re-tasked? Seems to me we're killing ourselves here, unneccessarily. Look, development is development. CCK is mostly in core anyway, so where does a questions like that belong? In the contrib-development mailing list or the core-development mailing list? ;) Carry on, mate. -- Joel Farris Transparatech, Inc "There are no mysteries here." G+ Skype Twitter: joelfarris
From: John Summerfield
Where, then, should those seeking help with module development turn? There's a themes list, but not one for modules.
participants (6)
-
Cameron B. Prince -
Joel Farris -
John Summerfield -
Ms. Nancy Wichmann -
Peter Droogmans -
郭赞