Troubleshooting field types
5 min read
A value is empty after saving
Field types clean every value. If the value does not fit, it is dropped and the field is saved empty; the previous value is not kept. The usual causes:
Type | Typical reason |
|---|---|
Number, Range | The text is not numeric ( |
The address is not valid. The field is saved empty ( | |
URL, oEmbed, Link | The scheme is unsafe or the address is unusable. A Link without a URL is empty even when it has link text. |
Color picker | Not a |
Date, Date and time, Time | The format is wrong or the day does not exist ( |
Select, Radio buttons, Button group, Checkboxes | The value is not one of the stored choice values. |
Image, File | The ID is not an attachment, is the wrong kind of file, or is not an allowed file type. |
Post object, Page link, Relationship | The post does not exist, is of another post type than the field allows, or the current user cannot read it. |
Taxonomy, User | The term or user does not exist, is in another taxonomy, or has a role that is not allowed. |
Map | Coordinates are out of range and there is no address. |
Icon picker | Not a Dashicons name. |
Each type page has a table of what it accepts.
wpmcf_get_field() returns something I did not expect
- A string where I expected a label. Choice fields return the stored value. Labels are only printed by
wpmcf_the_field()and the shortcode. 1instead oftrue. True / false returns a boolean at the top level, but1/0inside a Group or Repeater.- An ID instead of an object. Image, File, Post object, Page link, Relationship, Taxonomy and User return IDs. Turn them into data with the WordPress functions (
wp_get_attachment_url(),get_the_title(),get_term(),get_userdata()). - The password field returns a long string. That is the stored hash or encrypted value. Use
wpmcf_check_password()orwpmcf_get_password(). nullfor a field that has a default value. The default is applied when the object's row is created. Until something is saved for that object, there is no row. See Settings every field has.- JSON keys are in a different order. Read Group, Link and Map values by key.
wpmcf_update_field() did not do what I expected
- Most types sanitize instead of refusing: a value they cannot use is stored as empty, and
wpmcf_update_field()still returnstrue. It returnsfalsefor an unknown group, field or object, a failed write, and a value refused outright (for example a too short or too long Password). - It writes a Group, Repeater or other JSON value as a whole; partial arrays remove the rest.
- It does not check permissions or required fields. Check them in your own code.
- Checkboxes need an array; a single string clears the field.
Nothing is printed
See Output, formats and escaping. The most common reasons are an empty value, a Group (use path), a Password, a draft or private post in a relational field, or a shortcode id the visitor may not view.
Saving a field group fails
Message | Cause |
|---|---|
"Field key … is reserved" | The key is a MySQL word or a system column ( |
"…cannot be used inside another field" | A Group, Repeater, Password or Pro type was placed inside a Group or Repeater. |
"The default value does not fit this field type" | A Date, Time or Date and time default is not a complete value ( |
"clear Default Value when using a SQL column function" | A field with a column function cannot also have a default value. |
"Your plan does not include this field type" | You are adding a Pro type without the plan. See Pro field types. |
Changing a field's type
You can change a field's type in the builder. Changes between compatible types convert the column directly with no backup; other changes are risky, so the builder asks you to confirm and keeps a backup column. The data of renamed fields moves with them. See Field groups.
From | Converts directly to |
|---|---|
Text | Text area, Password, URL |
Text area | (none; other types need a confirmed conversion) |
Number | Range, Text, Text area, Email, URL, Password |
Range | Number, Text, Text area, Email, URL, Password |
Text, Text area, Password, URL | |
URL | Text area |
Password | Text area, Text |
Color picker | Text, Text area |
Select | Radio buttons, Text, Text area, Password, URL |
Radio buttons | Select, Text, Text area, Password, URL |
Button group | Select, Radio buttons, Text, Text area, Password, URL |
Checkboxes | Text area |
True / false | Number, Text, Text area |
Date | Date and time, Text, Text area |
Date and time, Time | Text, Text area |
Link, WYSIWYG editor, Group, Repeater, Relationship, Taxonomy, User | Text area |
oEmbed | URL, Text area |
Image | File |
File | Image |
Icon picker | Text, Text area |
Post object | Page link |
Page link | Post object |
Map, Accordion, Tab | (none) |
Choices survive a change between Select, Radio buttons, Checkboxes and Button group. Settings the new type does not understand are dropped.
Database column reference
The default column and the SQL types you may choose instead (field's SQL column options). Types not listed here have a fixed column.
Type | Default | You may choose |
|---|---|---|
Text |
|
|
Text area |
|
|
Number, Range |
|
|
|
| |
URL |
|
|
Password |
|
|
Color picker, Icon picker |
|
|
Select, Radio buttons, Button group |
|
|
True / false |
|
|
Date |
|
|
Date and time |
|
|
Time |
|
|
WYSIWYG editor |
|
|
oEmbed |
|
|
Image, File, Post object, Page link |
| fixed |
Checkboxes, Link, Map, Group, Repeater, Relationship, Taxonomy, User |
| fixed |
Accordion, Tab | none | none |
Indexing: types with number, date, short text or ID columns can have a normal index; TEXT and LONGTEXT columns are indexed by a prefix; JSON columns cannot be indexed (the Map's two coordinate columns share one index).
Still stuck?
Check WPM Fields › Settings › Health for logged errors, and see Field groups for the table health panel (drift between a field and its column).
Still stuck? Contact support