How to work with fields in Drupal 7?
One of the major differences of Drupal 7 from its previous versions is the in-built Field UI module: user interface to create and manage fields.
Fields are containers of specific information, such as text, image, link, file attachment, etc. They help you define what content you make available to your site users and how you display it. You can create your custom fields and also have some available with modules you add on to the Drupal core.
You can add required fields to any content type through menu Structure ⇾ Content types ⇾ manage fields.
- On the appearing screen you see “Add new field”.
- In the “Label” you add a name that is displayed in the user interface, and in the next box you enter a machine name. Use logical names to help you distinguish between the field types later. Example for a field intended for an image before text: Top image (label), field_image_top (machine name).
- Choose a field type according to the type of data you want to store in it: Image for pictures, link for URLs, etc. Be careful, because you cannot change field type after the field is created.
- Each field type also has a widget which provides an input element for editing (ex.: text area, select list, file upload, etc.). The widget can be changed after the field is created.
You can create as many new fields for your content type as needed or alternatively, you can use a field you created earlier for other content type: Add existing field.
You can edit the field you created to add description to it and change some settings, such as text format or number of values (number of times the users can enter data in this field).
Once your fields are created you can define how they are displayed in “manage display” screen. Here you can choose settings for label, define the image style, content format, etc. Note: when changing settings under the gear button, don’t forget to click first “Update”, and then “Save” at the bottom of the page.
In addition to fields you can create for content types as described above, you can also create fields
- on taxonomy terms: Structure ⇾ Taxonomy ⇾ edit vocabulary ⇾ manage fields.
- on user accounts: Configuration ⇾ Account settings ⇾ manage fields.
- on comments: Structure ⇾ Content types ⇾ manage fields ⇾ comment fields.
You can also add and customize field groups with the help of Field group module: http://drupal.org/project/field_group