Skip to content

The fields

Options every field accepts

KeyDefaultDescription
typeRequired. Field type
nameRequired. Storage key
label''Visible label
instructions''Help text below the label
requiredfalseShows the asterisk and adds required to the control
default_value''Value used before anything has been saved
placeholder''Placeholder text
wrapperarray()width as a percentage, plus extra class and id
conditional_logicarray()Rules deciding whether the field is shown

Available types

TypeOwn optionsNotes
textmaxlength, prepend, append
textarearows, maxlengthKeeps line breaks
numbermin, max, step, prepend, appendEmpty is stored as '', not 0
rangemin, max, step, prepend, appendSlider with a synced number input
emailmaxlength, prepend, appendSanitised with sanitize_email()
urlmaxlength, prepend, appendSanitised with sanitize_url(); print with esc_url()
passwordmaxlengthStored in plain text; don't use it for credentials
selectchoices, multiple, allow_nullNative, with fixed options
radiochoices, layout, allow_null
checkboxchoices, layoutStores an array
button_groupchoices, layout, allow_nullRadios styled as segmented buttons
true_falsemessage, ui, ui_on_text, ui_off_textStores 1 or 0; ui draws the switch
date_pickerreturn_format, min, maxNative control; stored as Ymd
time_pickerreturn_format, min, maxNative control; stored as H:i:s
date_time_pickerreturn_format, min, maxNative control; stored as Y-m-d H:i:s
color_pickerenable_opacity, paletteCore picker; hex, or rgba() with opacity
wysiwygtabs, toolbar, rows, media_upload, tableTinyMCE; works inside repeaters too
linkreturn_formatCore link modal; stores text, URL and target
oembedwidth, height, return_formatStores the URL; the HTML resolves at render time
imagepreview_size, library, mime_types, return_formatStores the ID; validated against the media library
filelibrary, mime_types, return_formatStores the attachment ID
gallerypreview_size, min, max, mime_types, return_formatOrdered list of images
icon_pickercollections, return_formatIconify search; stores mdi:home
messagemessage, esc_html, new_linesPresentation only, stores nothing
separatorPresentation only; the label titles the section
tabselected, endpointGroups the fields that follow into a tab
accordionopen, multi_expand, endpointNests the fields that follow into a collapsible panel
repeatersub_fields, min, max, button_labelList of rows; compatible with ACF's data
groupsub_fields, layoutSub-fields under a shared name, without repetition
flexible_contentlayouts, min, max, button_labelRows of different shapes, chosen by the editor
cloneclone, display, prefix_name, prefix_label, overridesPulls in a field set declared elsewhere
post_objectpost_type, taxonomy, post_status, multipleStores the post ID; searches over AJAX
page_linkthose of post_objectStores the ID; returns the permalink
relationshipfilters, min, max, plus those of post_objectTwo panels; preserves order
taxonomytaxonomy, field_type, hide_emptyCheckboxes, radios or a dropdown
userrole, multipleStores the user ID

Every one of them also accepts readonly and disabled.

What each field returns

WordPress hands back every meta value as a string. Forja returns them with their native type:

TypeReturnsWhen empty
numberint or floatnull
rangeint or floatthe minimum
true_falseboolfalse
image, fileper return_format0, '' or null
checkbox, multiple selectarrayarray()
repeater, flexible_contentarray of rowsarray()
grouparray keyed by sub-fieldarray()

An empty number returns null and not 0 on purpose: zero is a legitimate value, and conflating them would make "they didn't touch it" indistinguishable from "they typed zero".

Going deeper

Repeaters, flexible content, clone, conditional logic, the relational fields and the storage formats are documented in Spanish. Start at Los campos.

Released under the GPL-2.0-or-later licence.