Add a New Field

Go to admin/build/content where you will see a list of content types that are available. There are a couple included as a part of a standard Drupal installation, and you can use one of them or add a new content type of your own. For our example, let's add some fields to the 'story' content type.

Choose the option to 'edit' the 'story' type. Once you get to the screen where you can edit the content type, you will see additional tabs that say 'Manage fields', 'Display fields', and 'Add new field'. If you choose 'Manage fields' or 'Display fields' you will see nothing, since you have not yet created any fields, so start by selecting the option 'Add new field'.

On the 'Add new field' screen you will be asked for a name for the field. You can type anything here, including spaces, but whatever you type here will be used to create the actual field name that is used in the database. If you type 'My Text', the actual field name will become field_my_text. You'll use that field name later if you want to do any custom themeing.


The machine name of the field cannot be changed later!

Below the field name you will see a list of the fields that are available. The core fields are 'Text', 'Integer', 'Decimal', 'Nodereference', and 'Userreference'. Those are the types of content you can create with those fields. The 'Text' field will create content that is stored in the database as text. The 'Integer' and 'Decimal' fields create content that is stored in the database as numbers. Nodereference and Userreference store either the node or user ids in the database to allow you to link to those node or user records.

Under each type of field are several options for the way the data will be input for this field (CCK calls these 'widgets'). They control the way the input form will look for this field. The available options are different for each field, but include things like a text field, which is a blank box where a user can type text, auto-complete fields where a user can type text and the system will try to complete the text for them from values available in the database, select lists, checkboxes, and radios.

The screen will look like:

Create new field Name:

The T4Lftine-r44d4b e n»int of he field.

Alioi*2d chirortcrs i unorcer:uated a-2, lOTibirs aid _ All o&iei-tharartifris ¡J|l Ik discarded 1WI hp ctl* It ihHn ■ himrmditili l»b*l forth* f-IH on nf4 ml hiclr) type:

Nodi ReferennF © Select List

AufiKCmpl4t* Tent Field integer

Check braes/radio buttons © SiiKjkr ur^-'ulJ checkbox Decimal

O Text Field © Select list

Check boxes/radio buttons O Sinylt- QrVaH checkfco* Te/t

© Select list

© Ciieck boxesyradio buttons i'-1 Single on/off thetkJbox © Te>t Field Usei Refeience © Spied Ust

© Autocomplete Text Field [ Create field J

Start with something easy, a 'Text' field with a text field widget, by selecting 'Text' > 'Text Field'.

Next, you will be taken to a screen where you can define more things about the way this field will work. It will look like:

You'll notice that the list of possible widgets shows up again on this screen. That's because you have an option to change your field to use a different widget once the field has been created. Skip past this section for now.

Some of the things you can define include the following:

Create a label here. This is a chance to create a label that has different components than the machine name of the field. It can contain spaces or non-ASCII characters, and it can be changed later. The machine name cannot be changed.

This is an option that you only see for the 'Text' field. If you leave it set to '1', the default, you will get a regular textfield in your form, which will be stored as a varchar field in the database. If you choose a number greater than '1', you will get a large textarea in your form, set to the number of rows you select here, stored as a text field in the database.

• Default value

You'll see a collapsed area where you can input a default value for this field. You can use this or leave it blank.

If you have enabled the Fieldgroup module, you'll see an option to select a group to place this field into. If you have not created any groups, this won't have any effect.

Anything you type into the 'Help text' box will appear to end users as a description for this form element.

If you select the option to make this field required, users will have to fill this field out and will not be able to save new content without doing so.

• Multiple values

The multiple option is one of the most powerful and confusing parts of CCK. If selected, users will be able to select or create more than one of these items. One of the most common uses of this is to create a text or number field that uses a select or checkbox widget where you want to allow users to select more than one item.

• Text processing

This is another option that only applies to the Text field. Here you identify if the user should be allowed to select a filter for text processing. The option to use filter process will only make sense if the field is being created as a textarea field by selecting more than one row.

• Maximum length

Select the maximum length for the field or leave it blank for unlimited length. If this is a textfield, this value will be used to shorten the available field to the selected size.

• Allowed values list

This rarely will make any sense or be useful unless you choose to use a select or checkbox widget. If you use such a widget, this is where you can define the list of options that users can select from.

Select or fill out these values, then save the field. You'll be returned to the 'Manage Fields' screen.

Article Marketing Gold

Article Marketing Gold

Discover How You Can Use The Huge Power of Article Marketing To Drive Highly Targeted Traffic To Your Website and Instantly Become THE Person Your Prospects Want To Buy From.

Get My Free Ebook

Post a comment