Description
This function creates a form field.
Parameters
$args
(array)(required) An array of form field settings consisting of the following keys:
- @type string $name (required) The field meta key.
- @type string $type (required) The field HTML type (url, email, image, file, checkbox, text, textarea, password, hidden, select, multiselect, multicheckbox, radio).
- @type string $value (required) The field’s value (can be a null value).
- @type string $compare (required) Compare value.
- @type string $class (optional) Class identifier for the field.
- @type boolean $required (optional) If a value is required default: true).
- @type string $delimiter (optional) The field delimiter (pipe or comma, default: | ).
- @type string $placeholder (optional) Defines the placeholder attribute.
- @type string $pattern (optional) Adds a regex pattern to the field (HTML5).
- @type string $title (optional) Defines the title attribute.
- @type string $min (optional) Adds a min attribute (HTML5).
- @type string $max (optional) Adds a max attribute (HTML5).
Return Values
(string) The HTML of the form field.
Examples
General examples of creating a field:
Practical example using the wpmem_register_form_rows filter to create a new username field with placeholder text:
Changelog
Introduced in version 3.1.2
Source
wpmem_form_field() is located in /inc/api.php.