Add and configure fields
The Field module (GovCMS core) provides the configuration for fields and field attachments; the field types and input widgets themselves are provided by additional modules. Some of the modules are required, and the optional modules can be enabled from the Modules administration page (Administer → Modules).
GovCMS core includes the following field type modules: Text (required), Number, List, Taxonomy, Image, and File. Additional fields and widgets may be provided by contributed modules.
The Field module allows custom data fields to be attached to GovCMS entities (content nodes, users, taxonomy vocabularies, etc.) and takes care of storing, loading, editing, and rendering field data. Most users will not interact with the Field module directly, but will instead use the Field UI module user interface. Module developers can use the Field API to make new entities "fieldable" and allow fields to be attached to their entities.

Exercise 2.5: Modify an existing field

  1. 1.
    Go to Structure → Content types → Job posting → Manage fields
  2. 2.
    Click edit on the body field (this will only change the way the field appears in the Job posting content type, and not others)
  • Change the Label to “Job description”
  • Deselect Summary input
  1. 1.
    Click Save settings. Your field listing should show the new label.

Exercise 2.6: Add custom text field

For our Government Jobs Portal website, we want to let site visitors filter job offers by full time/part time. In this exercise, we’ll add this value in.
  1. 1.
    Add a field Let’s start by adding our first field – Terms of employment
  2. 2.
    Under Add a new field, scroll down and under Text, select List (text)
  • Enter “Terms of employment” for Label
  • For the Machine name, click edit and enter the machine name: jobterms
  • Click Save and continue
  1. 1.
    Click Save and continue and you’ll go back to the Field settings page for the Terms of employment field.
Review the Field naming conventions section below, before moving to the Field settings.
When adding a new field, GovCMS automatically suggests a field name. You can edit the field name when you’re adding it but cannot change it later on. When naming the field you should think carefully about a logical name, especially if you’ll be using the field in other content types.
The field name can only contain lowercase letters, numbers 0-9, and the underscore character. It’s a good idea to set up a naming convention early on.
To view the fields you’ve created, go to ReportsField list
  1. 1.
    Configure field settings
  2. 2.
    Next we’ll set up the values (items) for our dropdown list. Add the following options to the Allowed Values list text area:
1|Permanent 2|Temporary 3|Part-time 4|Full-time
  1. 1.
    You must include the numbers before each entry because they provide a numerical key for each option, which means you can change the names of the items without losing content.
  2. 2.
    Select “Limited” and “1” in the Allowed number of values.
  3. 3.
    Click Save field settings.
  4. 4.
    Configure default settings
Now you’ll see the Edit tab, with the field’s default settings. Follow these settings:
  • Select Required Field
  • Help text: “Please select terms of employment” (to be displayed when creating or editing Job Posting content)
  • Default value for Terms of employment: leave this as - None -
  • Click Save settings. You’ll then be returned to the Manage fields page
  1. 1.
    Manage Form display The Manage Form display tab allows you to control fields that will be available in the content creation form, along with widgets. This page is used to make adjustments to the widgets used in content types.
    Navigate to the Manage Form display page and review the available fields. Locate the “Terms of employment” field you created and review what widget selection is available.
  2. 2.
    Review your content type
Once you’ve saved your last field, you’ll be taken back to the Job Posting Manage fields page. All the fields you added to your content type will be visible here.
Finally, you should test the content type by adding content to it. Go to ContentAdd content and choose the “Job posting” option. Check the form and create a test job posting for a full-time job as a Drupal developer. Save the new job posting and note the URL path for the new content.

Exercise 2.7: Review the Field list report

  1. 1.
    Go to ReportsField list to see a list of fields added to your site
  2. 2.
    Delete any unused fields on your site
Remember, using common fields across multiple content types allows you to edit some global settings and values in one place.
Export as PDF
Copy link