text(sample)

Display a text input field.

Option Details & Parameters

Type: text

Returns: string

Can be placed in: Admin Panels , Admin Tabs , Meta Boxes , Theme Customizer

Parameter Type Description
name string The name of the option, for display purposes only.
id string A unique ID for this option. This ID will be used to get the value for this option.
desc string The description to display together with this option.
default string (Optional) The default value for this option.
livepreview string (Optional) jQuery code that updates something in your site in the live preview. Only used when the option is placed in a theme customizer section. Refer to Livepreview for more information on this parameter.
css string (Optional) CSS rules to be used with this option. Only used when the option is placed in an admin page / panel or a theme customizer section. Refer to Generate CSS Automatically for your options for more information on this parameter.
placeholder string (Optional) The text to display inside the text field when the field is empty
is_password boolean (Optional) If true, the field will be displayed as a password field. Defaults to false.
unit string Since v1.5.2
(Optional) An additional label, located immediately after the form field. Accepts alphanumerics and symbols. Potential applications include indication of the unit, especially if the field is used with numbers.
eg. If you use the field as input for numbers, like say, pixels, you would enter the value as ‘px’. Or, if as a unit of percentage, you’d enter ‘%’ as value.

Examples

Creating a text option:

$panel->createOption( array(
'name' => 'My Text Option',
'id' => 'my_text_option',
'type' => 'text',
'desc' => 'This is our option'
) );

Notes

[zilla_alert]When creating new options, the type setting defaults to type text when left blank.[/zilla_alert]