Adding a New Field (step 2)

Last modified: July 20, 2009 - 15:54

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

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:

Label

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.

Rows

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.

Group

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.

Help text

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

Required

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.

Save the field

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

php code example for allowed values in cck field

davidhunt - December 8, 2007 - 11:38

This is a silly bit of code that I wrote when I was experimenting with ways to give one content type access to taxonomy terms in a cck field without using taxonomy. The idea is probably useless but the code works. I put it here because it would be really nice to have one or two examples in the documentation for this section. It would have saved me a bunch of experimentation.

$terms = taxonomy_get_tree(1); //$terms will be an array of objects representing taxonomy terms

foreach($terms as $term) {
$term_names[] = $term->name; //$term_names will be an array consisting of the name of each taxonomy term
}

return $term_names;

Snippet: Creating CCK field's allowed values from...

rgammon - June 15, 2009 - 15:37

Added another snippet here: http://drupal.org/node/492288

"Snippet: Creating CCK field's allowed values from data in Node table"

CCK Text field Allowed Values List Limit

Stomper - December 22, 2009 - 00:01

I am running CCK in D6. What is the maximum number of options for the allowed values list for Select List Text Field. I would like to have a list of 3000+ options, will CCK allow this?

Is there any way to fill the allowed options list via some form of file import like .txt?

Thanks

 
 

Drupal is a registered trademark of Dries Buytaert.