# Exercise 2.6: Add a 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.

## Add a field

Let’s start by adding our first field – *Terms of employment*

1. Go to *Structure* → *Content types* → *Job posting* → **Manage fields** (if you have moved away from this page).
2. Click **+ Add field**.

   <img src="https://3186608908-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LzAsrTcKaHnLDg-7ALW%2Fuploads%2Fgit-blob-10b53cc4740a19a39ca89193c0fa0d93cffbd2e9%2FEx-2-6-Add-Field-1.png?alt=media" alt="Image of add Field" data-size="original">
3. 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**.

   <img src="https://3186608908-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LzAsrTcKaHnLDg-7ALW%2Fuploads%2Fgit-blob-15ed5a44892941bb16165e1c844bf63bf46d366f%2FEx-2-6-Add-Field-2.png?alt=media" alt="Image of add Field" data-size="original">
4. 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*.

### Field naming conventions

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.

![Image of auto suggested field name](https://3186608908-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LzAsrTcKaHnLDg-7ALW%2Fuploads%2Fgit-blob-a6ac2dcd57544738d6056f03ad016a270544ef73%2FEx-2-6-Add-Field-3.png?alt=media)

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.

## Configure field settings

Next we’ll set up the values (items) for our dropdown list.

1. Add the following options to the **Allowed Values list** text area:

   * 1|Permanent
   * 2|Temporary
   * 3|Part-time
   * 4|Full-time

   <img src="https://3186608908-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LzAsrTcKaHnLDg-7ALW%2Fuploads%2Fgit-blob-fcfb6c1eb19cb6b7e7c08ae3d98f976ff1a56cb6%2FEx-2-6-Add-Field-4.png?alt=media" alt="Image of allowed values list" data-size="original">

   > **Note** 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. Select “Limited” and “1” in the **Allowed number of values** dropdown and scrollwheel.
3. Click **Save field settings**.

## 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.

### 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.

![Image of Manage Form display](https://3186608908-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LzAsrTcKaHnLDg-7ALW%2Fuploads%2Fgit-blob-4be9b28688e5ae9ad937b375bb8048940f8b955c%2FEx-2-6-Add-Field-5.png?alt=media)

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.

## 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 add to your content type will be visible here.

Finally, you should test the content type by adding content to it.

Go to *Content* → *Add 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.

![Image of Manage Form display](https://3186608908-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LzAsrTcKaHnLDg-7ALW%2Fuploads%2Fgit-blob-997caccd71c1b6568d906ab09fd308a08edbe52f%2FEx-2-6-Add-Field-6.png?alt=media)

{% hint style="info" %}
To view the field you’ve created, go to *Reports* → **Field list**.
{% endhint %}
