Hi all,

i'm new to drupal, and drupal module development.

I'm just trying to develop a very simple custom field for drupal (just for learning purpose), but i cannot have it listed in the Fields menu.

The module code is here: http://pastebin.com/nqpY91QE
The module is correctly installed and recognized by drupal, but when i try to add a field it doesn't appear as an option.

I tried to follow several tutorial, but with no luck. Could you help me undersand what i'm missing???
Many thanks,
Ivan

Comments

pelach’s picture

download examples.
enable field_example module and take a look at the code. That got me started.

finarfin’s picture

Thank you, pelach.

I have another question.
My custom field need also a db entry for store the result and/or the currency? Or in that case it is managed by drupal?

jjkiesch’s picture

hook_field_schema() may be what you're looking for. you'll want that in your .install file to define your database.

gohyisheng’s picture

Yup, you need to implement the above hook so that Drupal can create the table to store your price field's data.

I personally found that looking at the database tables help a lot when I started out.

bjcone’s picture

The examples module is a good place to start though it doesn't give any information on "gotchas", etc which are helpful for newer developers (I just finished a project creating my own field type).

I wrote a brief overview of the process for just that purpose. Check it out at: http://clikfocus.com/blog/custom-field-type-using-fields-api .