Settings every field has
6 min read
Besides its own Type settings (described on each type's page), every field has the same set of options. You find them by opening a field in WPM Fields › Field Groups and using the Advanced options panel of the field. The tabs are Type settings, General, Validation, Display and Conditional logic. Field groups explains the builder itself; this page explains how the options behave per type.
General tab
Setting | Effect |
|---|---|
Default value | Written as the column's |
Placeholder | Grey hint text inside the control. Never stored. You may use |
Instructions | Help text shown under the control to editors. Plain text. |
Width | How much of the row the field takes on the edit screen: Full width, Three quarters, Two thirds, Half, One third or One quarter. |
Default values
- The default is part of the database column, so it is applied when a row is created for the object, that is, the first time any field of the group is saved for that post, user or term. Until then the object has no row, and
wpmcf_get_field()returnsnull(or thedefaultargument you pass, see below). - On the edit screen of a new object the control is prefilled with the default value.
- A default containing
{{ expression }}(for example{{ wp.post_title }}) is evaluated per object on the edit screen and is not stored as the SQL column default; the column gets no default, so objects that never open the edit screen start empty. - A default must fit the type. A Date or Time default must be a complete value in the column format (
2026-01-01,08:30:00); otherwise the group cannot be saved ("the default value does not fit this field type"). A Password never takes a default. - A field with a SQL column function (for example
upperormd5) cannot also have a default value. Clear it first. - Types that store JSON (Checkboxes, Link, Map, Group, Repeater, Relationship, Taxonomy, User) and the long text types (Text area, URL, WYSIWYG, oEmbed) cannot carry a database default. For those the default can only prefill a control that accepts plain text (for example a Text area); set structured values in code instead.
Separate from this, wpmcf_get_field() accepts a default argument that is returned when the value is empty:
$phone = wpmcf_get_field( 'company', 'phone', $post_id, [ 'default' => 'Not available' ] );The [wpmcf_field] shortcode accepts the same default="…". See Output, formats and escaping.
Constraints
Setting | Effect |
|---|---|
Required | Marks the field with an asterisk ( |
Add index | Adds a database index to the column (not available for JSON types). |
Unique | Makes the value unique across rows. Empty values are stored as |
Prefix length | For |
On the server, required is a warning, not a block: when the classic editor saves a post with an empty required field, the post is saved and an admin notice says "Saved, but these required fields are empty: …". The block editor locks the Save button. Values written through wpmcf_update_field() or the REST API are not checked for required.
Validation tab
The Validation rules shown depend on the type.
Rules shown | Types |
|---|---|
Min value, Max value, Step | Number, Range |
Min length, Max length (characters) | Text, Text area, Email, URL, Password |
"No extra validation rules available" | Choice types, Date and time types, Image, File, Link, Map, relational types, Group, Repeater |
What is enforced where:
Rule | In the browser | When saving (server) |
|---|---|---|
Max length |
| The text is cut to the length |
Min length |
| Not enforced (a script or REST call can save a shorter value). Password is the exception: the server refuses a password that is too short or too long |
Min value / Max value |
| The number is clamped into the range |
Step |
| Not enforced |
The Validation tab also shows the field's column (Column: with its SQL type) and the SQL column options such as the SQL type override. Each type page lists which SQL types it allows.
Display tab
These options apply when a value is printed with wpmcf_the_field() or [wpmcf_field]. They do not affect wpmcf_get_field().
Setting | Effect |
|---|---|
Prefix | Text printed before the value (added inside the wrapper), for example |
Suffix | Text printed after the value, for example |
Wrapper CSS class | Extra classes on the wrapping |
Wrapper HTML ID | An |
<!-- Prefix "$", suffix " USD", wrapper class "price" -->
<span class="wpmcf-field-value price">$19.9 USD</span>The wrapper is a <span class="wpmcf-field-value">. Turn it off with wrap="false" (shortcode) or 'wrap' => false (PHP) to get the bare output. Prefix and suffix are escaped as plain text.
Conditional logic
The Conditional logic tab (Enable conditional logic, Add condition) shows or hides a field on the edit screen depending on other fields in the same group, at the same level (a sub-field can only depend on its sibling sub-fields).
- Combine rules with and (all must match) or or (any matches).
- Operators: has value, is empty, equals, not equals, contains, not contains, greater than, less than.
- Lists (Checkboxes, Relationship and similar) count as "has value" when at least one item is picked, and
equalsmatches when one of the items equals the value. A True / false field compares as1(on) or0(off), so useequals 1for "is on". Because0counts as a value, "has value" is true for a True / false field whether it is on or off. - A rule that points at a field that does not exist passes.
Important behaviour:
- Hiding does not delete data. A hidden field still posts its stored value, so toggling a condition off and on never loses anything.
- A hidden field is never required, in the browser and on the server.
- Conditions only control the edit screen. Templates still read whatever is stored, so check the controlling field in your template if the hidden value should not be shown.
// Show the "reason" text only when the "refund" switch is on.
if ( wpmcf_get_field( 'order', 'refund' ) ) {
wpmcf_the_field( 'order', 'reason' );
}Variables in values
Text, Text area, Email and URL fields show a {} button on the edit screen to insert a {{ variable }} expression into the value. On output, expressions in these fields are resolved when the value's author is allowed to post unfiltered HTML. See Variables and hooks for the expression language. Values in comments are never resolved.
Troubleshooting
- "Field key is reserved" when saving the group: pick another key (see Field types overview).
- The default value does not show up in
wpmcf_get_field(): the object has no row yet; save any field of the group for it, or pass thedefaultargument. - A rule seems ignored: only max length and min/max value are enforced on the server; see the table above.
Still stuck? Contact support