Managing Other CCK Fields

If you have installed and enabled the basic CCK data type modules, including Number and Text along with Option Widgets, you will see that you can create other fields in the same way. For example, Figure 7.9 shows how you can add a text field with choices to enter a color.

FIGURE 7.9

Create a text field with specified values for radio buttons.

ROO story I I ocal host

« I ] I + http://localhost/-sams/demo_drupal/?q=admin/contefn/iiode-type/storyyfields

C I (O,* mysql data types jfeiler

My account Create content Administer

Content management Comments Content Content types Post settings

Reports Help

Story

Add fields and groups to the content type, and arrange them on content display and i You can add a field to a group by dragging it below and to the right of the group. Note: Installing the Advanced help module will let you access more and better help.

Label Name Type i

4. Menu settings Menu module form.

Taxonomy

+ File attachmen

s Upload module form.

Site building

4> Image

fieldjmage

File

Configure Remove

Site configuration

User management

Add

New field

After you create the field, you must provide the allowable values, as shown in Figure 7.10. This is not just a convenience for the user. By using filtered input, such as checkboxes or radio buttons, you know the range of values that may be entered. This lets you construct ad hoc queries without worrying about dirty data.

FIGURE 7.10

«no

Color | locaihost

Specify the

1 + http://localhost/-sams/demo_drupal/?q=admin/Gontent/node-type/story/fields/field_color& C | mysql data types

allowed values

for a check box or radio button field.

Create a list of options as a list in Allowed values list or as an array in PHP code. These values will be the same for Color in all content types.

The 'checkboxes/radio buttons' widget will display checkboxes if the multiple values option is selected for this field, otherwise radios will be displayed.

Allowed values list:

Black White

This will be

Purple

1

important in HOUR 14,

"WORKING WITH VIEWS,"

p. 237.

The possible values this field can contain. Enter one value per line, In the format key| label. The key Is the value that will be stored In the database, and It must match the field storage type (text). The label is optional, and the key will be used as the label If no label Is specified.

Allowed HTML tags: <a> <b> <blg> <code> <del> <em> <l> <lrts> <pre> <q> <small> <span> <strong> <sub> <sup> <tt> <ol> <ul> <ll> <p> <br> <lmg>

I

After you create these fields, whenever someone tries to enter a new story, the appropriate fields will automatically be created for the user. All you may want to do is move fields up and down in the Manage Fields list. Figure 7.11 shows the input page that is created for you.

FIGURE7.il

Drupal creates the user interface.

My aeci

Create content Page

Administer

Create Story | ocalhosr

Create Slory

Input Format

File attachments Revision InFormation Comment settings

0 0

Post a comment