Processwire fields and how to create them

Posted 6th Sep 2017

#fields #setup

We're going to look at processwire fields, what they are, and how you can create them.

Admin > Setup > Fields

Fields for your templates are listed on this page.

Creating a new field
Creating a new field Zoom

When you first create a field, you have a few options to begin with.

Name: The name of the field which is saved to the database. Use only ASCII letters (a-z A-Z), numbers (0-9) or underscores.

Type: Out the box options are:

  • Checkbox
  • Datetime
  • E-Mail
  • Fieldset (Open)
  • Fieldset in Tab (Open)
  • Files
  • Float
  • Images
  • Integer
  • Page Reference
  • Password
  • Text
  • Textarea
  • URL

Label: This is what will be displayed as the field label when the page is being edited.

Admin > Modules > Core (tab)

There are a couple of fields that are useful but disabled by default. They can be enabled and will then be selectable when you create a field.

  • Select Options
  • Repeater

So let's create a simple text field

Select the 'Add New field' button and fill in the 'Name', select a 'Type' (text) and fill in the 'Label'. Label is what will appear when a user edits a page which has this field on it.

Adding a text field
Adding a text field Zoom

Admin > Setup > Fields > Details (tab)

Automatic formatting of a text field
Automatic formatting of a text field Zoom

Text formatters: We don't want any HTML characters allowed so we can use automatic formatting of the field. Select 'HTML Entity Encoder (htmlspecialcharacters)'.

Admin > Setup > Fields > Input (tab)

The edit field input tab
The edit field input tab Zoom

Visibility: How the field will displayed on a page edit screen.

Column width: You can change the width of the column so that two or more fields can be horizontal on a page edit screen.

Required: Make this a required field. On page save, the user will get a warning that this field is required.

Min/Max length: Minimum and maximum length of acharacters allowed in the field.

Counter: No counter, character counter or word counter. If character/word counter selected, the maximum length setting above will be enforced but with handy twitter style character count.

Strip tags: Select this to strip all HTML tags from the field. Recommended if they are not required.

Placeholder text: This will be shown (slightly greyed) in the field itself. You could use it as a prompt i.e. if the field needs a name, you could write a placeholder like 'Enter name here'.

Pattern: Use this if your field needs a specific string inside, like a name with firstname and surname.

Front-end editing: Not enabled by default. You would need to install the front-end page editor module, but when installed, if a user has the correct permissions, they can double click on a piece of text output from this field and edit it right there on the web page, no admin area required. Which is pretty cool!

Admin > Setup > Fields > Access (tab)

The edit field access tab
The edit field access tab Zoom

No need to do anything here. You could control acces to the field if required.

Admin > Setup > Fields > Advanced (tab)

The edit field advanced tab
The edit field advanced tab Zoom

No need to do anything here. The descriptions are well written and self explanatory.

Admin > Setup > Fields > Actions (tab)

The edit field actions tab
The edit field actions tab Zoom

Add/remove: Super useful for batch adding or removing the field, to or from templates.

Duplicate/Clone: Duplicate or clone the field. This can save time if you need two fields of the same type but with partially different settings.

Check field data: Check for unused data and then provides options for next steps (optimization setting).

Admin > Setup > Fields > Delete (tab)

The edit field delete tab
The edit field delete tab Zoom

NOTE: Deleting the field will delete it from ALL templates that use it, thus also deleting the data.

If the field has been added to a template, you must remove that field from the template before deleting the field here.

So now you know how to create fields. As mentioned, processwire fields are added to templates so next you could learn about templates and how to create them or adding fields to templates.

Feedback & support

I hope you enjoyed this tutorial. You can support pwtuts by following on @pwtuts. You can also donate at paypal.me/swcarrey to help support the site which would be awesome!

Related tutorials / See all

Suggest a tutorial

Please note: I do not store any of this information, it's simply used to send me an email. Your email address is required so I can get clarification on your request if needed.